]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/graphs.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
13 # enable only the following on debugging purpose
15 use CGI
::Carp
'fatalsToBrowser';
17 require '/var/ipfire/general-functions.pl';
18 require "${General::swroot}/lang.pl";
19 require "${General::swroot}/header.pl";
20 require "${General::swroot}/graphs.pl";
29 &Header
::showhttpheaders
();
31 my $graphdir = "/srv/web/ipfire/html/graphs";
32 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
34 $ENV{'QUERY_STRING'} =~ s/&//g;
35 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
36 $cgigraphs[1] = '' unless defined $cgigraphs[1];
38 if ($cgigraphs[1] =~ /(load)/) {&Graphs
::updateloadgraph
("week");&Graphs
::updateloadgraph
("month");&Graphs
::updateloadgraph
("year");}
39 if ($cgigraphs[1] =~ /(cpu)/) {&Graphs
::updatecpugraph
("week");&Graphs
::updatecpugraph
("month");&Graphs
::updatecpugraph
("year");}
40 if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs
::updatememgraph
("week");&Graphs
::updatememgraph
("month");&Graphs
::updatememgraph
("year");}
41 if ($cgigraphs[1] =~ /disk/){
42 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
47 &Graphs
::updatediskgraph
("week",$device);
48 &Graphs
::updatediskgraph
("month",$device);
49 &Graphs
::updatediskgraph
("year",$device);}}
50 if ($cgigraphs[1] =~ /lq/) {&Graphs
::updatelqgraph
("week");&Graphs
::updatelqgraph
("month");&Graphs
::updatelqgraph
("year");}
51 if ($cgigraphs[1] =~ /RED/) {&Graphs
::updateifgraph
("RED", "week");&Graphs
::updateifgraph
("RED", "month");&Graphs
::updateifgraph
("RED", "year");}
52 if ($cgigraphs[1] =~ /GREEN/) {&Graphs
::updateifgraph
("GREEN", "week");&Graphs
::updateifgraph
("GREEN", "month");&Graphs
::updateifgraph
("GREEN", "year");}
53 if ($cgigraphs[1] =~ /BLUE/) {&Graphs
::updateifgraph
("BLUE", "week");&Graphs
::updateifgraph
("BLUE", "month");&Graphs
::updateifgraph
("BLUE", "year");}
54 if ($cgigraphs[1] =~ /ORANGE/) {&Graphs
::updateifgraph
("ORANGE", "week");&Graphs
::updateifgraph
("ORANGE", "month");&Graphs
::updateifgraph
("ORANGE", "year");}
56 if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
57 &Header
::openpage
($Lang::tr
{'network traffic graphs'}, 1, '');
59 &Header
::openpage
($Lang::tr
{'system graphs'}, 1, '');
62 &Header
::openbigbox
('100%', 'left');
64 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
65 my $graph = $cgigraphs[1];
66 my $graphname = ucfirst(lc($cgigraphs[1]));
67 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
69 if (-e
"$graphdir/${graph}-day.png") {
70 my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
72 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
73 print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
74 print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
75 print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
76 print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
78 print $Lang::tr
{'no information available'};
81 } elsif ($cgigraphs[1] =~ /network/) {
82 push (@graphs, ('GREEN'));
83 if ($netsettings{'BLUE_DEV'}) {
84 push (@graphs, ('BLUE')); }
85 if ($netsettings{'ORANGE_DEV'}) {
86 push (@graphs, ('ORANGE')); }
87 push (@graphs, ("RED"));
88 push (@graphs, ('lq'));
90 foreach my $graphname (@graphs) {
91 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
93 if (-e
"$graphdir/${graphname}-day.png") {
94 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
95 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
96 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
97 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
100 print $Lang::tr
{'no information available'};
107 &Header
::closebigbox
();
108 &Header
::closepage
();