]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/graphs.cgi
f19e5a618e4cc8cdf15a38badcb49c24df00a1b3
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|lq)/) {
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|lq|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|lq)/) {
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"));
77 push (@graphs, ('lq'));
79 foreach my $graphname (@graphs) {
80 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
82 if (-e
"$graphdir/${graphname}-day.png") {
83 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
84 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
85 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
86 print "<img src='/graphs/${graphname}-day.png' border='0' />";
89 print $Lang::tr
{'no information available'};
95 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
96 if (-e
"$graphdir/cpu-day.png") {
97 my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);
98 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
99 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
100 print "<img src='/graphs/cpu-day.png' border='0' />";
103 print $Lang::tr
{'no information available'};
108 &Header
::openbox
('100%', 'center', "Memory $Lang::tr{'graph'}");
109 if (-e
"$graphdir/memory-day.png") {
110 my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);
111 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
112 print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";
113 print "<img src='/graphs/memory-day.png' border='0' />";
116 print $Lang::tr
{'no information available'};
121 &Header
::openbox
('100%', 'center', "Swap $Lang::tr{'graph'}");
122 if (-e
"$graphdir/swap-day.png") {
123 my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);
124 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
125 print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";
126 print "<img src='/graphs/swap-day.png' border='0' />";
129 print $Lang::tr
{'no information available'};
134 &Header
::openbox
('100%', 'center', "Disk $Lang::tr{'graph'}");
135 if (-e
"$graphdir/disk-day.png") {
136 my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);
137 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
138 print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
139 print "<img src='/graphs/disk-day.png' border='0' />";
142 print $Lang::tr
{'no information available'};
148 &Header
::closebigbox
();
149 &Header
::closepage
();