]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/graphs.cgi
Ein Paar Dateien fuer die GPLv3 angepasst.
[ipfire-2.x.git] / html / cgi-bin / graphs.cgi
index 9c7743e7d6ecbbee184241e518df167133cd9f59..3c66db23bfbc301dd640ad70786c3520ffe25b10 100644 (file)
@@ -1,13 +1,23 @@
 #!/usr/bin/perl
-#
-# SmoothWall CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The SmoothWall Team
-#
-# $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $
-#
+###############################################################################
+#                                                                             #
+# 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;
 
@@ -18,6 +28,7 @@ use strict;
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
+require "${General::swroot}/graphs.pl";
 
 my %cgiparams=();
 my %pppsettings=();
@@ -35,30 +46,30 @@ $ENV{'QUERY_STRING'} =~ s/&//g;
 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
 $cgigraphs[1] = '' unless defined $cgigraphs[1];
 
+if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");}
+if ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");}
+if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");}
+if ($cgigraphs[1] =~ /disk/){
+          my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
+
+          foreach (@devices) {
+                my $device = $_;
+                chomp($device);
+                 &Graphs::updatediskgraph ("week",$device);
+                 &Graphs::updatediskgraph ("month",$device);
+                 &Graphs::updatediskgraph ("year",$device);}}
+if ($cgigraphs[1] =~ /lq/) {&Graphs::updatelqgraph("week");&Graphs::updatelqgraph("month");&Graphs::updatelqgraph("year");}
+if ($cgigraphs[1] =~ /RED/) {&Graphs::updateifgraph("RED", "week");&Graphs::updateifgraph("RED", "month");&Graphs::updateifgraph("RED", "year");}
+if ($cgigraphs[1] =~ /GREEN/) {&Graphs::updateifgraph("GREEN", "week");&Graphs::updateifgraph("GREEN", "month");&Graphs::updateifgraph("GREEN", "year");}
+if ($cgigraphs[1] =~ /BLUE/) {&Graphs::updateifgraph("BLUE", "week");&Graphs::updateifgraph("BLUE", "month");&Graphs::updateifgraph("BLUE", "year");}
+if ($cgigraphs[1] =~ /ORANGE/) {&Graphs::updateifgraph("ORANGE", "week");&Graphs::updateifgraph("ORANGE", "month");&Graphs::updateifgraph("ORANGE", "year");}
+
 if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
        &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
 } else {
        &Header::openpage($Lang::tr{'system graphs'}, 1, '');
 }
 
-sub diskbox {
- my $disk = $_[0];
-    if (-e "$graphdir/disk-$disk-day.png") {
-  
-         &Header::openbox('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}");
-         my $ftime = localtime((stat("$graphdir/disk-$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-$disk'>";
-         print "<img 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");
-         }     
-        &Header::closebox();
-  }
-}
-
 &Header::openbigbox('100%', 'left');
 
 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
@@ -70,22 +81,14 @@ if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
                my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
                print "<center>";
                print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
-               print "<img src='/graphs/${graph}-day.png' border='0' /><hr />";
-               print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";
-               print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";
-               print "<img src='/graphs/${graph}-year.png' border='0' />";
+               print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
+               print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
+               print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
+               print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
        } else {
                print $Lang::tr{'no information available'};
        }
        &Header::closebox();
-       print "<div align='center'><table width='80%'><tr><td align='center'>";
-       if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq)/) {
-               print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
-       } else {
-               print "<a href='/cgi-bin/graphs.cgi'>";
-       }
-       print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
-       ;
 } elsif ($cgigraphs[1] =~ /network/) {
        push (@graphs, ('GREEN'));
        if ($netsettings{'BLUE_DEV'}) {
@@ -102,7 +105,7 @@ if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
                        my $ftime = localtime((stat("$graphdir/${graphname}-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=$graphname'>";
-                       print "<img src='/graphs/${graphname}-day.png' border='0' />";
+                       print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
                        print "</a>";
                } else {
                        print $Lang::tr{'no information available'};
@@ -110,80 +113,6 @@ if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
                print "<br />\n";
                &Header::closebox();
        }
-} else {
-       &Header::openbox('100%', 'center', "CPU $Lang::tr{'graph'}");
-       if (-e "$graphdir/cpu-day.png") {
-               my $ftime = localtime((stat("$graphdir/cpu-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=cpu'>";
-               print "<img src='/graphs/cpu-day.png' border='0' />";
-               print "</a>";
-       } else {
-               print $Lang::tr{'no information available'};
-       }
-       print "<br />\n";
-       &Header::closebox();
-
-       &Header::openbox('100%', 'center', "Load $Lang::tr{'graph'}");
-       if (-e "$graphdir/load-day.png") {
-               my $ftime = localtime((stat("$graphdir/load-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=load'>";
-               print "<img src='/graphs/load-day.png' border='0' />";
-               print "</a>";
-       } else {
-               print $Lang::tr{'no information available'};
-       }
-       print "<br />\n";
-       &Header::closebox();
-
-       &Header::openbox('100%', 'center', "Memory $Lang::tr{'graph'}");
-       if (-e "$graphdir/memory-day.png") {
-               my $ftime = localtime((stat("$graphdir/memory-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=memory'>";
-               print "<img src='/graphs/memory-day.png' border='0' />";
-               print "</a>";
-       } else {
-               print $Lang::tr{'no information available'};
-       }
-       print "<br />\n";
-       &Header::closebox();
-
-       &Header::openbox('100%', 'center', "Swap $Lang::tr{'graph'}");
-       if (-e "$graphdir/swap-day.png") {
-               my $ftime = localtime((stat("$graphdir/swap-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=swap'>";
-               print "<img src='/graphs/swap-day.png' border='0' />";
-               print "</a>";
-       } else {
-               print $Lang::tr{'no information available'};
-       }
-       print "<br />\n";
-       &Header::closebox();
-
-       &Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");
-       if (-e "$graphdir/disk-day.png") {
-               my $ftime = localtime((stat("$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 src='/graphs/disk-day.png' border='0' />";
-               print "</a>";
-       } else {
-               print $Lang::tr{'no information available'};
-       }
-       print "<br />\n";
-       &Header::closebox();
-
-    diskbox("hda");
-    diskbox("hdb");
-    diskbox("hdc");
-    diskbox("hdd");
-    diskbox("hde");
-    diskbox("hdf");
-    diskbox("hdg");
-    diskbox("hdh");
 }
 
 &Header::closebigbox();