]>
git.ipfire.org Git - 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";
28 &Header
::showhttpheaders
();
30 my $graphdir = "/srv/web/ipfire/html/graphs";
31 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
33 $ENV{'QUERY_STRING'} =~ s/&//g;
34 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
35 $cgigraphs[1] = '' unless defined $cgigraphs[1];
37 if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
38 &Header
::openpage
($Lang::tr
{'network traffic graphs'}, 1, '');
40 &Header
::openpage
($Lang::tr
{'system graphs'}, 1, '');
43 &Header
::openbigbox
('100%', 'left');
45 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
46 my $graph = $cgigraphs[1];
47 my $graphname = ucfirst(lc($cgigraphs[1]));
48 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
50 if (-e
"$graphdir/${graph}-day.png") {
51 my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
53 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
54 print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
55 print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
56 print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
57 print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
59 print $Lang::tr
{'no information available'};
62 } elsif ($cgigraphs[1] =~ /network/) {
63 push (@graphs, ('GREEN'));
64 if ($netsettings{'BLUE_DEV'}) {
65 push (@graphs, ('BLUE')); }
66 if ($netsettings{'ORANGE_DEV'}) {
67 push (@graphs, ('ORANGE')); }
68 push (@graphs, ("RED"));
69 push (@graphs, ('lq'));
71 foreach my $graphname (@graphs) {
72 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
74 if (-e
"$graphdir/${graphname}-day.png") {
75 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
76 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
77 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
78 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
81 print $Lang::tr
{'no information available'};
88 &Header
::closebigbox
();