]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
Meine Platte zur hddtemp.db hinzugefuegt
authormaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Sun, 23 Sep 2007 08:12:07 +0000 (08:12 +0000)
committermaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Sun, 23 Sep 2007 08:12:07 +0000 (08:12 +0000)
hddshutdown Routine verbessert

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@915 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

config/cfgroot/graphs.pl
config/etc/hddtemp.db
src/scripts/hddshutdown
src/scripts/makegraphs

index 4573449dc8047e38299c922e80f7a649cca3124e..804b70a059de5b63e3408252df9fe1181c4f310c 100644 (file)
@@ -230,6 +230,9 @@ sub updatediskgraph {
         "-t $Lang::tr{'disk access per'} $Lang::tr{$period} $disk",
         "DEF:read=$rrdlog/disk-$disk.rrd:readsect:AVERAGE",
         "DEF:write=$rrdlog/disk-$disk.rrd:writesect:AVERAGE",
+        "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
+        "CDEF:st=standby,INF,*",
+        "AREA:st".$color{"color19"}.":standby\\j",
         "AREA:read".$color{"color11"}.":$Lang::tr{'sectors read from disk per second'}",
         "STACK:write".$color{"color12"}.":$Lang::tr{'sectors written to disk per second'}\\j",
         "COMMENT: \\j",
@@ -367,6 +370,9 @@ sub updatehddgraph {
   "--color", "BACK".$color{"color21"},
   "-t $Lang::tr{'harddisk temperature'} ($Lang::tr{'graph per'} $Lang::tr{$period})",
   "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE",
+  "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE",
+  "CDEF:st=standby,INF,*",
+  "AREA:st".$color{"color19"}.":standby\\j",
   "LINE2:temperature".$color{"color11"}.":$Lang::tr{'hdd temperature in'} C\\j",
   "COMMENT:$Lang::tr{'maximal'}",
   "COMMENT:$Lang::tr{'average'}",
index 4a061cfcb6deb713e03991d6ee9226a6a45fa484..a0110fde8a7485e820504c4fc6d0304e39d3084c 100644 (file)
 #"SAMSUNG SV1204H"                                     194  C  "Samsung 120G"
 "SAMSUNG SV(0401|0802|1203|1604)N"                     194  C  "Samsung SpinPoint V80 serie"
 "SAMSUNG SV4012H"                                      194  C  "Samsung 40GB, 5400RPM, 2MB cache"
+"SAMSUNG HM100JC"         194  C  "Samsung 100GB,5400RPM, 8MB cache"
+
+
 
 ########################################
 ############# Seagate drives
index 853f769e4bffe5961e458224c45169699f4416ed..1a7a1d56f2e05b84822f7285401d6b59418c275a 100644 (file)
@@ -5,7 +5,7 @@
 # This code is distributed under the terms of the GPL
 #
 # 18.09.2007 Maniacikarus - IPFire.org - maniacikarus@ipfire.org
-#
+# 22.09.2007 Arne_F -  fitzenreiter.de - arne@fitzenreiter.de
 
 # begin
 
@@ -13,38 +13,48 @@ my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
 my $diskstats = "";
 my $newdiskstats = "";
 my $debug = 1;
-my $status = "unknown";
+my $status = "";
 
 if ($debug){print "### Searching for available Disks ###\n";}
 
 foreach (@devices){
-chomp $_;
-$diskstats = `iostat -d -t $_ | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
-
-if ( $_ =~ /^s/ ){$status = `sdparm --command=ready /dev/$_ | tail -1`;}
-else {$status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;}
-
-chomp $status;
-chomp $diskstats;
-if ($debug){print "Device ".$_." is in status ".$status." and has ".$diskstats." write and read Requests.\n";}
-sleep 30;
-
-$newdiskstats = `iostat -d -t $_ | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
-chomp $newdiskstats;
-
-  if ($diskstats eq $newdiskstats && $status !~/standby/){
-      if ($debug){print "Device ".$_." is set to standy.\n";}
-      if ( $_ =~ /^s/ ){system("sdparm --command=stop /dev/$_");}
-      else {system("/sbin/hdparm -y /dev/$_");}
-      system("touch /tmp/hddshutdown-$_");
-  }
-  elsif ($diskstatus{$_} ne "0" ){
-    if ($debug){print "Device ".$_." is active.\n";}
-    if ( -e "/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }
-  }
-  elsif ( $status =~/standby/ ){
-    if ($debug){print "Device ".$_." is in standby mode.\n";}
-  }
+    chomp $_;
+    $diskstats = `cat /tmp/hddstats-$_`;
+    chomp $diskstats;
+    $newdiskstats = `iostat -d -t $_ | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
+    chomp $newdiskstats;
+    $status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;
+    chomp $status;
+
+    if ($debug){print "Device ".$_." IDE Power status:".$status."\n";}
+    if (-e "/tmp/hddshutdown-$_" && $status !~/standby/)
+    {
+       if ($debug){print "Remove wrong standby marking\n";}
+       if ( -e "/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); } 
+    }
+
+    if ($debug){print "Device ".$_." has ".$newdiskstats." write and read Requests, was ".$diskstats." at last run.\n";}
+    if ($diskstats eq $newdiskstats && (! -e "/tmp/hddshutdown-$_") )
+    {
+       if ($debug){print "Setting Device ".$_." to standby ... ";}
+       $status = `hdparm -y /dev/$_ 2>&1`;
+       chomp $status;
+       if ($status !~/failed/) 
+       {  
+           if ($debug){print "OK\n";}
+           system("touch /tmp/hddshutdown-$_");
+       }
+       else
+       {
+           if ($debug){print "FAIL\n";}         
+       }
+    }
+    if ($diskstats ne $newdiskstats)
+    {
+       if ($debug){print "Device ".$_." is active.\n";}
+       if ( -e "/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }
+    }
+    system("echo $newdiskstats > /tmp/hddstats-$_");
 }
 
 # end
index ef959684b3129ffb4dd9574602e0545dd618878f..eb1ee439bc67b9015c1f8c4cd79caf98021f2044 100644 (file)
@@ -403,6 +403,28 @@ sub updatelq {
 sub updatehdddata 
 {
   my $disk = $_[0];
+  my $standby;
+  
+  if ( ! -e "$rrdlog/hddshutdown-$disk.rrd") 
+  {
+    # database did not exist -> create
+    RRDs::create ("$rrdlog/hddshutdown-$disk.rrd", "--step=300",
+      "DS:standby:GAUGE:600:0:1",
+      "RRA:AVERAGE:0.5:1:576",
+      "RRA:AVERAGE:0.5:6:672",
+      "RRA:AVERAGE:0.5:24:732",
+      "RRA:AVERAGE:0.5:144:1460");
+    $ERROR = RRDs::error;
+    print "Error in RRD::create for hddshutdown-$disk: $ERROR\n" if $ERROR;
+  }
+
+  if (-e "/tmp/hddshutdown-$disk") {$standby = 1;}
+    else {$standby = 0;}
+
+  RRDs::update ("$rrdlog/hddshutdown-$disk.rrd", "-t", "standby", "N:$standby");
+  $ERROR = RRDs::error;
+  print "Error in RRD::update for hddshutdown-$disk: $ERROR\n" if $ERROR;
+
   if ( ! -e "$rrdlog/hddtemp-$disk.rrd") 
   {
     # database did not exist -> create
@@ -415,62 +437,70 @@ sub updatehdddata
     $ERROR = RRDs::error;
     print "Error in RRD::create for hdd-$disk: $ERROR\n" if $ERROR;
   }
-  $temp = 0;
-  my $hdd_output = '';
-  my $smart_output = '';
-  
-  if ( -e "$path_smartctl" )
-  {
-    system("$path_smartctl -iHA -d ata /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
-  }
 
-  if ( -e "$path_hddtemp" )
+  # Temperaturlesen wÃrde die Platte aufwecken!!!
+  if (!$standby) 
   {
-    $hdd_output = `$path_hddtemp -qn /dev/$disk`;
-    
-    # I know 4 response possible responses:
-    #
-    # /dev/harddisk: harddisk type: S.M.A.R.T. not available
-    # /dev/harddisk: harddisk type: no sensor
-    # /dev/harddisk: harddisk type: 37?C or ?F
-    # 37
-
-    if ( index($hdd_output, "S.M.A.R.T.") != -1 )
+    $temp = 0;
+    my $hdd_output = '';
+    my $smart_output = '';
+  
+    if ( -e "$path_smartctl" )
     {
-      $temp = 0;
+       system("$path_smartctl -iHA -d ata /dev/$disk > /var/log/smartctl_out_hddtemp-$disk");
     }
-    elsif ( index($hdd_output, "no sensor") != -1 )
+
+    if ( -e "$path_hddtemp" )
     {
-      $temp = 1;
+       $hdd_output = `$path_hddtemp -qn /dev/$disk`;
+    
+       # I know 4 response possible responses:
+       #
+       # /dev/harddisk: harddisk type: S.M.A.R.T. not available
+       # /dev/harddisk: harddisk type: no sensor
+       # /dev/harddisk: harddisk type: 37?C or ?F
+       # 37
+
+       if ( index($hdd_output, "S.M.A.R.T.") != -1 )
+       {
+           $temp = 0;
+       }
+       elsif ( index($hdd_output, "no sensor") != -1 )
+       {
+           $temp = 1;
+       }
+       elsif ( index($hdd_output, "$disk") != -1 )
+       {
+           $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
+           $temp = $1;
+       }
+       else
+       {
+           $hdd_output =~ /(\d+)\s/;
+           $temp = $1;
+       }
     }
-    elsif ( index($hdd_output, "$disk") != -1 )
+    elsif ( -e "/var/log/smartctl_out_hddtemp-$disk" )
     {
-      $hdd_output =~ /.*:.*:\s*(\d+).*\s/;
-      $temp = $1;
+       $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`;
+       my @t = split(/\s+/,$hdd_output);
+       $temp = $t[9];
     }
     else
     {
-      $hdd_output =~ /(\d+)\s/;
-      $temp = $1;
+       $temp = 0;
     }
-  }
-  elsif ( -e "/var/log/smartctl_out_hddtemp-$disk" )
-  {
-    $hdd_output = `cat /var/log/smartctl_out_hddtemp-$disk | grep Temperature_`;
-    my @t = split(/\s+/,$hdd_output);
-    $temp = $t[9];
-  }
-  else
-  {
-    $temp = 0;
-  }
   
 
-  print "Temperature for ".$disk."->".$temp."<-\n";
-
-  RRDs::update ("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
-  $ERROR = RRDs::error;
-  print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
+    print "Temperature for ".$disk."->".$temp."<-\n";
+    # Nur ins RDD wenn nicht 0 (sonst klappt die min Anzeige nicht)
+    if ($temp)
+    {
+       RRDs::update ("$rrdlog/hddtemp-$disk.rrd", "-t", "temperature", "N:$temp");
+       $ERROR = RRDs::error;
+       print "Error in RRD::update for hdd-$disk: $ERROR\n" if $ERROR;
+    }
+  }
 }
 
 sub updatembmondata 
@@ -572,13 +602,42 @@ my $disk = $_;
 chomp $disk;
 print "Working on disk ".$disk.".\n";
 
-updatediskdata($disk);
-updatehdddata($disk);
+my $status = "";
+my $diskstats = "";
+my $newdiskstats = "";
 
+$diskstats = `cat /tmp/hddstats-$disk`;
+chomp $diskstats;
+my $newdiskstats = `/usr/bin/iostat -d -t $disk | tail -2 | head -1 | awk '{ print \$5","\$6}'`;
+chomp $newdiskstats;
 my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
+chomp $status;
+
+if ($status !~/standby/ || $diskstats ne $newdiskstats)
+{
+    if (-e "/tmp/hddshutdown-$disk") 
+    {
+      system("unlink /tmp/hddshutdown-$disk");
+    }
+}
+
+if (-e "/tmp/hddshutdown-$disk")  
+{
+    $status = " standby\n";
+}
+else
+{
+    $status = " active\n";
+}
+
+
 open(DATEI, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
 print DATEI $disk."-".$status;
 close(DATEI);
+
+updatediskdata($disk);
+updatehdddata($disk);
+
 }
 
 ###