]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/graphs.cgi
GeƤndert:
[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
18require 'CONFIG_ROOT/general-functions.pl';
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}
43&Header::openbigbox('100%', 'left');
44
072cd997 45if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk)/) {
ac1cfefa
MT
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'>";
072cd997 63 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq)/) {
ac1cfefa
MT
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"));
072cd997 77 push (@graphs, ('lq'));
ac1cfefa
MT
78
79 foreach my $graphname (@graphs) {
80 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
81
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' />";
87 print "</a>";
88 } else {
89 print $Lang::tr{'no information available'};
90 }
91 print "<br />\n";
92 &Header::closebox();
93 }
94} else {
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' />";
101 print "</a>";
102 } else {
103 print $Lang::tr{'no information available'};
104 }
105 print "<br />\n";
106 &Header::closebox();
107
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' />";
114 print "</a>";
115 } else {
116 print $Lang::tr{'no information available'};
117 }
118 print "<br />\n";
119 &Header::closebox();
120
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' />";
127 print "</a>";
128 } else {
129 print $Lang::tr{'no information available'};
130 }
131 print "<br />\n";
132 &Header::closebox();
133
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' />";
140 print "</a>";
141 } else {
142 print $Lang::tr{'no information available'};
143 }
144 print "<br />\n";
145 &Header::closebox();
146}
147
148&Header::closebigbox();
149&Header::closepage();