]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | use strict; | |
12 | ||
13 | # enable only the following on debugging purpose | |
14 | #use warnings; | |
15 | #use CGI::Carp 'fatalsToBrowser'; | |
16 | ||
986e08d9 | 17 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
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 | ||
fd0763dc | 30 | my $graphdir = "/srv/web/ipfire/html/graphs"; |
ac1cfefa MT |
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 | ||
072cd997 | 37 | if ($cgigraphs[1] =~ /(network|GREEN|BLUE|ORANGE|RED|lq)/) { |
ac1cfefa MT |
38 | &Header::openpage($Lang::tr{'network traffic graphs'}, 1, ''); |
39 | } else { | |
40 | &Header::openpage($Lang::tr{'system graphs'}, 1, ''); | |
41 | } | |
6c666a3b | 42 | |
ac1cfefa MT |
43 | &Header::openbigbox('100%', 'left'); |
44 | ||
207cc1cf | 45 | if ($cgigraphs[1] =~ /(GREEN|BLUE|ORANGE|RED|lq|cpu|memory|swap|disk|load)/) { |
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"; | |
e455cafe MT |
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' />"; | |
ac1cfefa MT |
58 | } else { |
59 | print $Lang::tr{'no information available'}; | |
60 | } | |
61 | &Header::closebox(); | |
ac1cfefa MT |
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")); | |
072cd997 | 69 | push (@graphs, ('lq')); |
ac1cfefa MT |
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'>"; | |
e455cafe | 78 | print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />"; |
ac1cfefa MT |
79 | print "</a>"; |
80 | } else { | |
81 | print $Lang::tr{'no information available'}; | |
82 | } | |
83 | print "<br />\n"; | |
84 | &Header::closebox(); | |
85 | } | |
ac1cfefa MT |
86 | } |
87 | ||
88 | &Header::closebigbox(); | |
89 | &Header::closepage(); |