]>
git.ipfire.org Git - people/teissler/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
9 # $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $
14 # enable only the following on debugging purpose
16 #use CGI::Carp 'fatalsToBrowser';
18 require 'CONFIG_ROOT/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
29 &Header
::showhttpheaders
();
31 my $graphdir = "/home/httpd/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] =~ /(network|GREEN|BLUE|ORANGE|RED)/) {
39 &Header
::openpage
($Lang::tr
{'network traffic graphs'}, 1, '');
41 &Header
::openpage
($Lang::tr
{'system graphs'}, 1, '');
43 &Header
::openbigbox
('100%', 'left');
45 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|cpu|memory|swap|disk)/) {
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 src='/graphs/${graph}-day.png' border='0' /><hr />";
55 print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";
56 print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";
57 print "<img src='/graphs/${graph}-year.png' border='0' />";
59 print $Lang::tr
{'no information available'};
62 print "<div align='center'><table width='80%'><tr><td align='center'>";
63 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED)/) {
64 print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
66 print "<a href='/cgi-bin/graphs.cgi'>";
68 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
70 } elsif ($cgigraphs[1] =~ /network/) {
71 push (@graphs, ('GREEN'));
72 if ($netsettings{'BLUE_DEV'}) {
73 push (@graphs, ('BLUE')); }
74 if ($netsettings{'ORANGE_DEV'}) {
75 push (@graphs, ('ORANGE')); }
76 push (@graphs, ("RED"));
78 foreach my $graphname (@graphs) {
79 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
81 if (-e
"$graphdir/${graphname}-day.png") {
82 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
83 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
84 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
85 print "<img src='/graphs/${graphname}-day.png' border='0' />";
88 print $Lang::tr
{'no information available'};
94 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
95 if (-e
"$graphdir/cpu-day.png") {
96 my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);
97 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
98 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
99 print "<img src='/graphs/cpu-day.png' border='0' />";
102 print $Lang::tr
{'no information available'};
107 &Header
::openbox
('100%', 'center', "Memory $Lang::tr{'graph'}");
108 if (-e
"$graphdir/memory-day.png") {
109 my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);
110 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
111 print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";
112 print "<img src='/graphs/memory-day.png' border='0' />";
115 print $Lang::tr
{'no information available'};
120 &Header
::openbox
('100%', 'center', "Swap $Lang::tr{'graph'}");
121 if (-e
"$graphdir/swap-day.png") {
122 my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);
123 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
124 print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";
125 print "<img src='/graphs/swap-day.png' border='0' />";
128 print $Lang::tr
{'no information available'};
133 &Header
::openbox
('100%', 'center', "Disk $Lang::tr{'graph'}");
134 if (-e
"$graphdir/disk-day.png") {
135 my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);
136 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
137 print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
138 print "<img src='/graphs/disk-day.png' border='0' />";
141 print $Lang::tr
{'no information available'};
147 &Header
::closebigbox
();
148 &Header
::closepage
();