]>
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 '/var/ipfire/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, '');
46 if (-e
"$graphdir/disk-$disk-day.png") {
48 &Header
::openbox
('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}");
49 my $ftime = localtime((stat("$graphdir/disk-$disk-day.png"))[9]);
50 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
51 print "<a href='/cgi-bin/graphs.cgi?graph=disk-$disk'>";
52 print "<img src='/graphs/disk-$disk-day.png' border='0' />";
55 if (-e
"/usr/local/bin/hddshutdown-state") {
56 system("/usr/local/bin/hddshutdown-state $disk");
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 src='/graphs/${graph}-day.png' border='0' /><hr />";
74 print "<img src='/graphs/${graph}-week.png' border='0' /><hr />";
75 print "<img src='/graphs/${graph}-month.png' border='0' /><hr />";
76 print "<img src='/graphs/${graph}-year.png' border='0' />";
78 print $Lang::tr
{'no information available'};
81 print "<div align='center'><table width='80%'><tr><td align='center'>";
82 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq)/) {
83 print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
85 print "<a href='/cgi-bin/graphs.cgi'>";
87 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
89 } elsif ($cgigraphs[1] =~ /network/) {
90 push (@graphs, ('GREEN'));
91 if ($netsettings{'BLUE_DEV'}) {
92 push (@graphs, ('BLUE')); }
93 if ($netsettings{'ORANGE_DEV'}) {
94 push (@graphs, ('ORANGE')); }
95 push (@graphs, ("RED"));
96 push (@graphs, ('lq'));
98 foreach my $graphname (@graphs) {
99 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
101 if (-e
"$graphdir/${graphname}-day.png") {
102 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
103 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
104 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
105 print "<img src='/graphs/${graphname}-day.png' border='0' />";
108 print $Lang::tr
{'no information available'};
114 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
115 if (-e
"$graphdir/cpu-day.png") {
116 my $ftime = localtime((stat("$graphdir/cpu-day.png"))[9]);
117 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
118 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
119 print "<img src='/graphs/cpu-day.png' border='0' />";
122 print $Lang::tr
{'no information available'};
127 &Header
::openbox
('100%', 'center', "Load $Lang::tr{'graph'}");
128 if (-e
"$graphdir/load-day.png") {
129 my $ftime = localtime((stat("$graphdir/load-day.png"))[9]);
130 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
131 print "<a href='/cgi-bin/graphs.cgi?graph=load'>";
132 print "<img src='/graphs/load-day.png' border='0' />";
135 print $Lang::tr
{'no information available'};
140 &Header
::openbox
('100%', 'center', "Memory $Lang::tr{'graph'}");
141 if (-e
"$graphdir/memory-day.png") {
142 my $ftime = localtime((stat("$graphdir/memory-day.png"))[9]);
143 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
144 print "<a href='/cgi-bin/graphs.cgi?graph=memory'>";
145 print "<img src='/graphs/memory-day.png' border='0' />";
148 print $Lang::tr
{'no information available'};
153 &Header
::openbox
('100%', 'center', "Swap $Lang::tr{'graph'}");
154 if (-e
"$graphdir/swap-day.png") {
155 my $ftime = localtime((stat("$graphdir/swap-day.png"))[9]);
156 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
157 print "<a href='/cgi-bin/graphs.cgi?graph=swap'>";
158 print "<img src='/graphs/swap-day.png' border='0' />";
161 print $Lang::tr
{'no information available'};
166 &Header
::openbox
('100%', 'center', "Disk $Lang::tr{'graph'}");
167 if (-e
"$graphdir/disk-day.png") {
168 my $ftime = localtime((stat("$graphdir/disk-day.png"))[9]);
169 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
170 print "<a href='/cgi-bin/graphs.cgi?graph=disk'>";
171 print "<img src='/graphs/disk-day.png' border='0' />";
174 print $Lang::tr
{'no information available'};
189 &Header
::closebigbox
();
190 &Header
::closepage
();