]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/media.cgi
Ein Paar Dateien fuer die GPLv3 angepasst.
[ipfire-2.x.git] / html / cgi-bin / media.cgi
index 5f9662317ca1ede2e7f79855d6406dca928f8923..be02f489dd8f9da7b8487b16145d09f0f53f3dc2 100644 (file)
@@ -1,22 +1,34 @@
 #!/usr/bin/perl
-#
-# SmoothWall CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The SmoothWall Team
-#
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 use strict;
 
 # enable only the following on debugging purpose
-use warnings;
-use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
+require "${General::swroot}/graphs.pl";
 
 #workaround to suppress a warning when a variable is used only once
 my @dummy = ( ${Header::colourred} );
@@ -32,24 +44,12 @@ my %cgiparams=();
 
 &Header::openbigbox('100%', 'left');
 
-&Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");
-if (-e "$Header::graphdir/disk-day.png") {
-       my $ftime = localtime((stat("$Header::graphdir/disk-day.png"))[9]);
-       print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
-       print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
-       print "<img alt='' src='/graphs/disk-day.png' border='0' />";
-       print "</a>";
-} else {
-       print $Lang::tr{'no information available'};
-}
-print "<br />\n";
-&Header::closebox();
-
 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
 
 foreach (@devices) {
        my $device = $_;
        chomp($device);
+       &Graphs::updatediskgraph ("day",$device);
        diskbox("$device");
 }
 
@@ -146,7 +146,7 @@ my $i=0;
 for(my $i = 1; $i <= $#iostat1; $i++)
 {
 if ( $i eq '1' ){print "<tr><td align='center' class='boldbase'><b>Device</b></td><td align='center' class='boldbase'><b>MB read</b></td><td align='center' class='boldbase'><b>MB writen</b></td></tr>";}
-else {print "<tr><td align='center'>@iostat1[$i]</td><td align='center'>@iostat2[$i]</td><td align='center'>@iostat3[$i]</td></tr>";}
+else {print "<tr><td align='center'>$iostat1[$i]</td><td align='center'>$iostat2[$i]</td><td align='center'>$iostat3[$i]</td></tr>";}
 }
 print "</table>\n";
 &Header::closebox();
@@ -184,6 +184,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]);
@@ -192,9 +194,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-state") {
-                   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
@@ -206,6 +223,4 @@ END
 ;
       &Header::closebox();
                }
-
-  
 }