]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/graphs.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
40 &Header
::showhttpheaders
();
42 my $graphdir = "/srv/web/ipfire/html/graphs";
43 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
45 $ENV{'QUERY_STRING'} =~ s/&//g;
46 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
47 $cgigraphs[1] = '' unless defined $cgigraphs[1];
49 if ($cgigraphs[1] =~ /(load)/) {&Graphs
::updateloadgraph
("hour");&Graphs
::updateloadgraph
("week");&Graphs
::updateloadgraph
("month");&Graphs
::updateloadgraph
("year");}
50 if ($cgigraphs[1] =~ /(cpu)/) {&Graphs
::updatecpugraph
("hour");&Graphs
::updatecpugraph
("week");&Graphs
::updatecpugraph
("month");&Graphs
::updatecpugraph
("year");}
51 if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs
::updatememgraph
("hour");&Graphs
::updatememgraph
("week");&Graphs
::updatememgraph
("month");&Graphs
::updatememgraph
("year");}
52 if ($cgigraphs[1] =~ /disk/){
53 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
57 &Graphs
::updatediskgraph
("hour",$device);
58 &Graphs
::updatediskgraph
("week",$device);
59 &Graphs
::updatediskgraph
("month",$device);
60 &Graphs
::updatediskgraph
("year",$device);}}
61 if ($cgigraphs[1] =~ /lq/) {&Graphs
::updatelqgraph
("hour");&Graphs
::updatelqgraph
("week");&Graphs
::updatelqgraph
("month");&Graphs
::updatelqgraph
("year");}
62 if ($cgigraphs[1] =~ /fwhits/) {&Graphs
::updatefwhitsgraph
("hour");&Graphs
::updatefwhitsgraph
("week");&Graphs
::updatefwhitsgraph
("month");&Graphs
::updatefwhitsgraph
("year");}
63 if ($cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /ipsec/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /red/ ) {&Graphs
::updateifgraph
($cgigraphs[1], "hour");&Graphs
::updateifgraph
($cgigraphs[1], "week");&Graphs
::updateifgraph
($cgigraphs[1], "month");&Graphs
::updateifgraph
($cgigraphs[1], "year");}
65 if ($cgigraphs[1] =~ /(network|green|blue|orange|red|ipsec|lq)/) {
66 &Header
::openpage
($Lang::tr
{'network traffic graphs'}, 1, '');
68 &Header
::openpage
($Lang::tr
{'system graphs'}, 1, '');
71 &Header
::openbigbox
('100%', 'left');
73 if ($cgigraphs[1] =~ /(green|blue|orange|red|ipsec|lq|cpu|memory|swap|disk|load|fwhits)/) {
74 my $graph = $cgigraphs[1];
75 my $graphname = ucfirst(lc($cgigraphs[1]));
76 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
78 if (-e
"$graphdir/${graph}-day.png") {
79 my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
81 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
82 print "<img alt='' src='/graphs/${graph}-hour.png' border='0' /><hr />";
83 print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
84 print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
85 print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
86 print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
88 print $Lang::tr
{'no information available'};
91 } elsif ($cgigraphs[1] =~ /network/) {
92 push (@graphs, ('GREEN'));
93 if ($netsettings{'BLUE_DEV'}) {
94 push (@graphs, ('BLUE')); }
95 if ($netsettings{'ORANGE_DEV'}) {
96 push (@graphs, ('ORANGE')); }
97 push (@graphs, ("RED"));
98 push (@graphs, ('lq'));
100 foreach my $graphname (@graphs) {
101 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
103 if (-e
"$graphdir/${graphname}-day.png") {
104 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
105 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
106 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
107 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
110 print $Lang::tr
{'no information available'};
117 print "<div align='center'><table width='80%'><tr><td align='center'>";
118 if ( $cgigraphs[1] eq "cpu" || $cgigraphs[1] eq "load" ) { print "<a href='/cgi-bin/system.cgi'>"; }
119 elsif ( $cgigraphs[1] eq "memory" || $cgigraphs[1] eq "swap" ) { print "<a href='/cgi-bin/memory.cgi'>"; }
120 elsif ( $cgigraphs[1] =~ /disk/ ) { print "<a href='/cgi-bin/media.cgi'>"; }
121 elsif ( $cgigraphs[1] =~ /red/ || $cgigraphs[1] =~ /ipsec/ ) { print "<a href='/cgi-bin/network.cgi?network=red'>"; }
122 elsif ( $cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /orange/ ) { print "<a href='/cgi-bin/network.cgi?network=internal'>"; }
123 elsif ( $cgigraphs[1] eq "fwhits" || $cgigraphs[1] eq "lq" ) { print "<a href='/cgi-bin/network.cgi?network=other'>"; }
124 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
126 &Header
::closebigbox
();
127 &Header
::closepage
();