]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Hddstatus auf der Media CGI nochmal ueberarbeitet
authormaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Tue, 21 Aug 2007 17:11:33 +0000 (17:11 +0000)
committermaniacikarus <maniacikarus@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Tue, 21 Aug 2007 17:11:33 +0000 (17:11 +0000)
git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@796 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

html/cgi-bin/media.cgi
src/scripts/hddshutdown
src/scripts/makegraphs

index 2cb1d4a377e05f2be8033bca7fc46ff78d02a298..19a34107593dab9ff96a31bb5f5ab2165205e04f 100644 (file)
@@ -173,6 +173,8 @@ END
 
 sub diskbox {
  my $disk = $_[0];
+ chomp $disk;
+ my @status;
     if (-e "$Header::graphdir/disk-$disk-day.png") {
                  &Header::openbox('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}");
                  my $ftime = localtime((stat("$Header::graphdir/disk-$disk-day.png"))[9]);
@@ -181,9 +183,24 @@ sub diskbox {
                  print "<img alt='' src='/graphs/disk-$disk-day.png' border='0' />";
                  print "</a>";
                  print "<br />\n";
-                 if (-e "/usr/local/bin/hddshutdown") {
-                   system("/usr/local/bin/hddshutdown state $disk");
-                 }
+
+      if (-e "/tmp/hddstatus") {
+        open(DATEI, "</tmp/hddstatus") || die "Datei nicht gefunden";
+        my  @diskstate = <DATEI>;
+        close(DATEI);
+
+        foreach (@diskstate){
+          if ( $_ =~/$disk/ ){@status = split(/-/,$_);}
+        }
+
+        if ( $status[1]=~/standby/){
+          my $ftime = localtime((stat("/tmp/hddshutdown-$disk"))[9]);
+          print"<B>Disk /dev/$disk status:<font color=#FF0000>".$status[1]."</font></B> (since $ftime)";
+        }
+        else{
+          print"<B>Disk /dev/$disk status:<font color=#00FF00>".$status[1]."</font></B>";
+        }
+      }
                  my $smart = `/usr/local/bin/smartctrl $disk`;
                        $smart = &Header::cleanhtml($smart);
                        print <<END
index ac91382b1e0bb8c160583a67425ed10b81f6cd48..6bd24104f0bb91a9753072469d32062871b73b9c 100644 (file)
 my @proc = `cat /proc/diskstats`;
 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
 my %diskstatus = "";
+my %diskstate = "";
 my $debug = 1;
 my $status = "unknown";
 
-if ( @ARGV[0] eq "state" ){
-my $hdd = @ARGV[1];
-$status = `hdparm -C /dev/$hdd | tail -1 | cut -d: -f2`;
-
-if ( $status=~/standby/){
-  my $ftime = localtime((stat("/tmp/hddshutdown-$hdd"))[9]);
-  print"<B>Disk $hdd status: <font color=#00FF00>standby</font></B> (since $ftime)";
-  }
-else{
-  print"<B>Disk $hdd status: <font color=#FF0000>active</font></B>";
-  }
-exit;
-}
-
 if ($debug){print "### Reading Diskstats ###\n";}
 
 foreach (@proc){
@@ -54,4 +41,5 @@ $status = `hdparm -C /dev/$_ | tail -1 | cut -d: -f2`;
     if ( -e "/tmp/hddshutdown-$_" ) { system("unlink /tmp/hddshutdown-$_"); }
   }
 }
+
 # end
index 4e22159457f2f10ef222e06a65a3bb74f7249dc1..f98e37758408387106a6e2c09a5d1f7b0d213200 100644 (file)
@@ -415,7 +415,6 @@ 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 = '';
@@ -564,14 +563,22 @@ updatememdata();
 ### HDD graphs
 ###
 
+
 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
+system("unlink /tmp/hddstatus && touch /tmp/hddstatus");
 print "\nFound following amount of disks:".@disks."\n";
 foreach (@disks){
 my $disk = $_;
 chomp $disk;
 print "Working on disk ".$disk.".\n";
+
 updatediskdata($disk);
 updatehdddata($disk);
+
+my $status = `hdparm -C /dev/$disk | tail -1 | cut -d: -f2`;
+open(DATEI, ">>/tmp/hddstatus") || die "Datei nicht gefunden";
+print DATEI $disk."-".$status;
+close(DATEI);
 }
 
 ###