]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/graphs.cgi
makegraphs umgebaut, sodass nurnoch rrd daten geschrieben werden die graphen
[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 #
10
11 use strict;
12
13 # enable only the following on debugging purpose
14 #use warnings;
15 #use CGI::Carp 'fatalsToBrowser';
16
17 require '/var/ipfire/general-functions.pl';
18 require "${General::swroot}/lang.pl";
19 require "${General::swroot}/header.pl";
20
21 my %cgiparams=();
22 my %pppsettings=();
23 my %netsettings=();
24 my @cgigraphs=();
25 my @graphs=();
26 my $iface='';
27
28 &Header::showhttpheaders();
29
30 my $graphdir = "/srv/web/ipfire/html/graphs";
31 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
32
33 $ENV{'QUERY_STRING'} =~ s/&//g;
34 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
35 $cgigraphs[1] = '' unless defined $cgigraphs[1];
36
37 if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) {
38 &Header::openpage($Lang::tr{'network traffic graphs'}, 1, '');
39 } else {
40 &Header::openpage($Lang::tr{'system graphs'}, 1, '');
41 }
42
43 &Header::openbigbox('100%', 'left');
44
45 if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) {
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 alt='' src='/graphs/${graph}-day.png' border='0' /><hr />";
55 print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />";
56 print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />";
57 print "<img alt='' src='/graphs/${graph}-year.png' border='0' />";
58 } else {
59 print $Lang::tr{'no information available'};
60 }
61 &Header::closebox();
62 } elsif ($cgigraphs[1] =~ /network/) {
63 push (@graphs, ('GREEN'));
64 if ($netsettings{'BLUE_DEV'}) {
65 push (@graphs, ('BLUE')); }
66 if ($netsettings{'ORANGE_DEV'}) {
67 push (@graphs, ('ORANGE')); }
68 push (@graphs, ("RED"));
69 push (@graphs, ('lq'));
70
71 foreach my $graphname (@graphs) {
72 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
73
74 if (-e "$graphdir/${graphname}-day.png") {
75 my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]);
76 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
77 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
78 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
79 print "</a>";
80 } else {
81 print $Lang::tr{'no information available'};
82 }
83 print "<br />\n";
84 &Header::closebox();
85 }
86 }
87
88 &Header::closebigbox();
89 &Header::closepage();