]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/graphs.cgi
Debuginformationen aus den CGIs entfernt
[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#
ac1cfefa
MT
9#
10
11use strict;
12
13# enable only the following on debugging purpose
cb5e9c6c
CS
14#use warnings;
15#use CGI::Carp 'fatalsToBrowser';
ac1cfefa 16
986e08d9 17require '/var/ipfire/general-functions.pl';
ac1cfefa
MT
18require "${General::swroot}/lang.pl";
19require "${General::swroot}/header.pl";
b05768be 20require "${General::swroot}/graphs.pl";
ac1cfefa
MT
21
22my %cgiparams=();
23my %pppsettings=();
24my %netsettings=();
25my @cgigraphs=();
26my @graphs=();
27my $iface='';
28
29&Header::showhttpheaders();
30
fd0763dc 31my $graphdir = "/srv/web/ipfire/html/graphs";
ac1cfefa
MT
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
b05768be
CS
38if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");}
39if ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");}
40if ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");}
41if ($cgigraphs[1] =~ /disk/){
42 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
43
44 foreach (@devices) {
45 my $device = $_;
46 chomp($device);
47 &Graphs::updatediskgraph ("week",$device);
48 &Graphs::updatediskgraph ("month",$device);
49 &Graphs::updatediskgraph ("year",$device);}}
50if ($cgigraphs[1] =~ /lq/) {&Graphs::updatelqgraph("week");&Graphs::updatelqgraph("month");&Graphs::updatelqgraph("year");}
51if ($cgigraphs[1] =~ /RED/) {&Graphs::updateifgraph("RED", "week");&Graphs::updateifgraph("RED", "month");&Graphs::updateifgraph("RED", "year");}
52if ($cgigraphs[1] =~ /GREEN/) {&Graphs::updateifgraph("GREEN", "week");&Graphs::updateifgraph("GREEN", "month");&Graphs::updateifgraph("GREEN", "year");}
53if ($cgigraphs[1] =~ /BLUE/) {&Graphs::updateifgraph("BLUE", "week");&Graphs::updateifgraph("BLUE", "month");&Graphs::updateifgraph("BLUE", "year");}
54if ($cgigraphs[1] =~ /ORANGE/) {&Graphs::updateifgraph("ORANGE", "week");&Graphs::updateifgraph("ORANGE", "month");&Graphs::updateifgraph("ORANGE", "year");}
55
072cd997 56if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
ac1cfefa
MT
57 &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
58} else {
59 &Header::openpage($Lang::tr{'system graphs'}, 1, '');
60}
6c666a3b 61
ac1cfefa
MT
62&Header::openbigbox('100%', 'left');
63
207cc1cf 64if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
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";
e455cafe
MT
73 print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
74 print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
75 print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
76 print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
ac1cfefa
MT
77 } else {
78 print $Lang::tr{'no information available'};
79 }
80 &Header::closebox();
ac1cfefa
MT
81} elsif ($cgigraphs[1] =~ /network/) {
82 push (@graphs, ('GREEN'));
83 if ($netsettings{'BLUE_DEV'}) {
84 push (@graphs, ('BLUE')); }
85 if ($netsettings{'ORANGE_DEV'}) {
86 push (@graphs, ('ORANGE')); }
87 push (@graphs, ("RED"));
072cd997 88 push (@graphs, ('lq'));
ac1cfefa
MT
89
90 foreach my $graphname (@graphs) {
91 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
92
93 if (-e "$graphdir/${graphname}-day.png") {
94 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
95 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
96 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
e455cafe 97 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
ac1cfefa
MT
98 print "</a>";
99 } else {
100 print $Lang::tr{'no information available'};
101 }
102 print "<br />\n";
103 &Header::closebox();
104 }
ac1cfefa
MT
105}
106
107&Header::closebigbox();
108&Header::closepage();