]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/graphs.cgi
git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848...
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / graphs.cgi
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
12 use strict;
13
14 # enable only the following on debugging purpose
15 #use warnings;
16 #use CGI::Carp 'fatalsToBrowser';
17
18 require 'CONFIG_ROOT/general-functions.pl';
19 require "${General::swroot}/lang.pl";
20 require "${General::swroot}/header.pl";
21
22 my %cgiparams=();
23 my %pppsettings=();
24 my %netsettings=();
25 my @cgigraphs=();
26 my @graphs=();
27 my $iface='';
28
29 &Header::showhttpheaders();
30
31 my $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
38 if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED)/) {
39 &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
40 } else {
41 &Header::openpage($Lang::tr{'system graphs'}, 1, '');
42 }
43 &Header::openbigbox('100%', 'left');
44
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'}");
49
50 if (-e "$graphdir/${graph}-day.png") {
51 my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
52 print "<center>";
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' />";
58 } else {
59 print $Lang::tr{'no information available'};
60 }
61 &Header::closebox();
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'>";
65 } else {
66 print "<a href='/cgi-bin/graphs.cgi'>";
67 }
68 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
69 ;
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
78 foreach my $graphname (@graphs) {
79 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
80
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' />";
86 print "</a>";
87 } else {
88 print $Lang::tr{'no information available'};
89 }
90 print "<br />\n";
91 &Header::closebox();
92 }
93 } else {
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' />";
100 print "</a>";
101 } else {
102 print $Lang::tr{'no information available'};
103 }
104 print "<br />\n";
105 &Header::closebox();
106
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' />";
113 print "</a>";
114 } else {
115 print $Lang::tr{'no information available'};
116 }
117 print "<br />\n";
118 &Header::closebox();
119
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' />";
126 print "</a>";
127 } else {
128 print $Lang::tr{'no information available'};
129 }
130 print "<br />\n";
131 &Header::closebox();
132
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' />";
139 print "</a>";
140 } else {
141 print $Lang::tr{'no information available'};
142 }
143 print "<br />\n";
144 &Header::closebox();
145 }
146
147 &Header::closebigbox();
148 &Header::closepage();