]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/graphs.cgi
HinzugefĆ¼gt:
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / graphs.cgi
CommitLineData
ac1cfefa
MT
1#!/usr/bin/perl
2#
3# SmoothWall CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The SmoothWall Team
8#
9# $Id: graphs.cgi,v 1.9.2.6 2005/02/22 22:21:55 gespinasse Exp $
10#
11
12use strict;
13
14# enable only the following on debugging purpose
15#use warnings;
16#use CGI::Carp 'fatalsToBrowser';
17
986e08d9 18require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
19require "${General::swroot}/lang.pl";
20require "${General::swroot}/header.pl";
21
22my %cgiparams=();
23my %pppsettings=();
24my %netsettings=();
25my @cgigraphs=();
26my @graphs=();
27my $iface='';
28
29&Header::showhttpheaders();
30
31my $graphdir = "/home/httpd/html/graphs";
32&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
33
34$ENV{'QUERY_STRING'} =~ s/&//g;
35@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
36$cgigraphs[1] = '' unless defined $cgigraphs[1];
37
072cd997 38if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
ac1cfefa
MT
39 &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
40} else {
41 &Header::openpage($Lang::tr{'system graphs'}, 1, '');
42}
6c666a3b
MT
43
44sub diskbox {
45 my $disk = $_[0];
46 if (-e "$graphdir/disk-$disk-day.png") {
47
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' />";
53 print "</a>";
54 print "<br />\n";
55 if (-e "/usr/local/bin/hddshutdown-state") {
56 system("/usr/local/bin/hddshutdown-state $disk");
57 }
58 &Header::closebox();
59 }
60}
61
ac1cfefa
MT
62&Header::openbigbox('100%', 'left');
63
072cd997 64if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk)/) {
ac1cfefa
MT
65 my $graph = $cgigraphs[1];
66 my $graphname = ucfirst(lc($cgigraphs[1]));
67 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
68
69 if (-e "$graphdir/${graph}-day.png") {
70 my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
71 print "<center>";
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' />";
77 } else {
78 print $Lang::tr{'no information available'};
79 }
80 &Header::closebox();
81 print "<div align='center'><table width='80%'><tr><td align='center'>";
072cd997 82 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq)/) {
ac1cfefa
MT
83 print "<a href='/cgi-bin/graphs.cgi?graph=network'>";
84 } else {
85 print "<a href='/cgi-bin/graphs.cgi'>";
86 }
87 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
88 ;
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"));
072cd997 96 push (@graphs, ('lq'));
ac1cfefa
MT
97
98 foreach my $graphname (@graphs) {
99 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
100
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' />";
106 print "</a>";
107 } else {
108 print $Lang::tr{'no information available'};
109 }
110 print "<br />\n";
111 &Header::closebox();
112 }
113} else {
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' />";
120 print "</a>";
121 } else {
122 print $Lang::tr{'no information available'};
123 }
124 print "<br />\n";
125 &Header::closebox();
126
127 &Header::openbox('100%', 'center', "Memory $Lang::tr{'graph'}");
128 if (-e "$graphdir/memory-day.png") {
129 my $ftime = localtime((stat("$graphdir/memory-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=memory'>";
132 print "<img src='/graphs/memory-day.png' border='0' />";
133 print "</a>";
134 } else {
135 print $Lang::tr{'no information available'};
136 }
137 print "<br />\n";
138 &Header::closebox();
139
140 &Header::openbox('100%', 'center', "Swap $Lang::tr{'graph'}");
141 if (-e "$graphdir/swap-day.png") {
142 my $ftime = localtime((stat("$graphdir/swap-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=swap'>";
145 print "<img src='/graphs/swap-day.png' border='0' />";
146 print "</a>";
147 } else {
148 print $Lang::tr{'no information available'};
149 }
150 print "<br />\n";
151 &Header::closebox();
152
153 &Header::openbox('100%', 'center', "Disk $Lang::tr{'graph'}");
154 if (-e "$graphdir/disk-day.png") {
155 my $ftime = localtime((stat("$graphdir/disk-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=disk'>";
158 print "<img src='/graphs/disk-day.png' border='0' />";
159 print "</a>";
160 } else {
161 print $Lang::tr{'no information available'};
162 }
163 print "<br />\n";
164 &Header::closebox();
6c666a3b
MT
165
166 diskbox("hda");
167 diskbox("hdb");
168 diskbox("hdc");
169 diskbox("hdd");
170 diskbox("hde");
171 diskbox("hdf");
172 diskbox("hdg");
173 diskbox("hdh");
ac1cfefa
MT
174}
175
176&Header::closebigbox();
177&Header::closepage();