]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
25 | #use warnings; | |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
27 | ||
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
31 | require "${General::swroot}/graphs.pl"; | |
32 | ||
33 | my %cgiparams=(); | |
34 | my %pppsettings=(); | |
35 | my %netsettings=(); | |
36 | my @cgigraphs=(); | |
37 | my @graphs=(); | |
38 | my $iface=''; | |
39 | ||
40 | &Header::showhttpheaders(); | |
41 | ||
42 | my $graphdir = "/srv/web/ipfire/html/graphs"; | |
43 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
44 | ||
45 | $ENV{'QUERY_STRING'} =~ s/&//g; | |
46 | @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'}); | |
47 | $cgigraphs[1] = '' unless defined $cgigraphs[1]; | |
48 | $cgigraphs[2] = '' unless defined $cgigraphs[2]; | |
49 | ||
50 | if ($cgigraphs[1] =~ /(load)/) {&Graphs::updateloadgraph ("hour");&Graphs::updateloadgraph ("week");&Graphs::updateloadgraph ("month");&Graphs::updateloadgraph ("year");} | |
51 | elsif ($cgigraphs[1] =~ /(cpu)/) {&Graphs::updatecpugraph ("hour");&Graphs::updatecpugraph ("week");&Graphs::updatecpugraph ("month");&Graphs::updatecpugraph ("year");} | |
52 | elsif ($cgigraphs[1] =~ /(processes)/) {&Graphs::updateprocessesgraph ("hour");&Graphs::updateprocessesgraph ("week");&Graphs::updateprocessesgraph ("month");&Graphs::updateprocessesgraph ("year");} | |
53 | elsif ($cgigraphs[1] =~ /(memory|swap)/) {&Graphs::updatememgraph ("hour");&Graphs::updatememgraph ("week");&Graphs::updatememgraph ("month");&Graphs::updatememgraph ("year");} | |
54 | elsif ($cgigraphs[1] =~ /wireless/){ &Graphs::wireless("hour",$cgigraphs[2]); &Graphs::wireless("week",$cgigraphs[2]); &Graphs::wireless("month",$cgigraphs[2]); &Graphs::wireless("year",$cgigraphs[2]); } | |
55 | elsif ($cgigraphs[1] =~ /disk/){ | |
56 | my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; | |
57 | foreach (@devices) { | |
58 | my $device = $_; | |
59 | chomp($device); | |
60 | &Graphs::updatediskgraph ("hour",$device); | |
61 | &Graphs::updatediskgraph ("week",$device); | |
62 | &Graphs::updatediskgraph ("month",$device); | |
63 | &Graphs::updatediskgraph ("year",$device);}} | |
64 | elsif ($cgigraphs[2] ne "" ) {&Graphs::updatepinggraph("hour",$cgigraphs[1]);&Graphs::updatepinggraph("week",$cgigraphs[1]);&Graphs::updatepinggraph("month",$cgigraphs[1]);&Graphs::updatepinggraph("year",$cgigraphs[1]);} | |
65 | elsif ($cgigraphs[1] =~ /fwhits/) {&Graphs::updatefwhitsgraph("hour");&Graphs::updatefwhitsgraph("week");&Graphs::updatefwhitsgraph("month");&Graphs::updatefwhitsgraph("year");} | |
66 | elsif ($cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /ipsec/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /ppp/ || $cgigraphs[1] =~ /red/ ) {&Graphs::updateifgraph($cgigraphs[1], "hour");&Graphs::updateifgraph($cgigraphs[1], "week");&Graphs::updateifgraph($cgigraphs[1], "month");&Graphs::updateifgraph($cgigraphs[1], "year");} | |
67 | ||
68 | if ($cgigraphs[1] =~ /(network|green|blue|orange|red|ppp|ipsec)/ || $cgigraphs[2] ne "") { | |
69 | &Header::openpage($Lang::tr{'network traffic graphs'}, 1, ''); | |
70 | } else { | |
71 | &Header::openpage($Lang::tr{'system graphs'}, 1, ''); | |
72 | } | |
73 | ||
74 | &Header::openbigbox('100%', 'left'); | |
75 | ||
76 | if ($cgigraphs[1] =~ /wireless/){ | |
77 | my $graphname = $cgigraphs[2]; | |
78 | &Header::openbox('100%', 'center', "wireless $graphname $Lang::tr{'graph'}"); | |
79 | if (-e "$graphdir/wireless-${graphname}-day.png") { | |
80 | my $ftime = localtime((stat("$graphdir/wireless-${graphname}-day.png"))[9]); | |
81 | print "<center>"; | |
82 | print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n"; | |
83 | print "<img alt='' src='/graphs/wireless-${graphname}-hour.png' border='0' /><hr />"; | |
84 | print "<img alt='' src='/graphs/wireless-${graphname}-day.png' border='0' /><hr />"; | |
85 | print "<img alt='' src='/graphs/wireless-${graphname}-week.png' border='0' /><hr />"; | |
86 | print "<img alt='' src='/graphs/wireless-${graphname}-month.png' border='0' /><hr />"; | |
87 | print "<img alt='' src='/graphs/wireless-${graphname}-year.png' border='0' />"; | |
88 | } else { | |
89 | print $Lang::tr{'no information available'}; | |
90 | } | |
91 | &Header::closebox(); | |
92 | } | |
93 | elsif ($cgigraphs[1] =~ /(green|blue|orange|red|ppp|ipsec|cpu|memory|swap|disk|load|fwhits|processes)/ || $cgigraphs[2] ne "") { | |
94 | my $graph = $cgigraphs[1]; | |
95 | my $graphname = ucfirst(lc($cgigraphs[1])); | |
96 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); | |
97 | ||
98 | if (-e "$graphdir/${graph}-day.png") { | |
99 | my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]); | |
100 | print "<center>"; | |
101 | print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n"; | |
102 | print "<img alt='' src='/graphs/${graph}-hour.png' border='0' /><hr />"; | |
103 | print "<img alt='' src='/graphs/${graph}-day.png' border='0' /><hr />"; | |
104 | print "<img alt='' src='/graphs/${graph}-week.png' border='0' /><hr />"; | |
105 | print "<img alt='' src='/graphs/${graph}-month.png' border='0' /><hr />"; | |
106 | print "<img alt='' src='/graphs/${graph}-year.png' border='0' />"; | |
107 | } else { | |
108 | print $Lang::tr{'no information available'}; | |
109 | } | |
110 | &Header::closebox(); | |
111 | } elsif ($cgigraphs[1] =~ /network/) { | |
112 | push (@graphs, ('GREEN')); | |
113 | if ($netsettings{'BLUE_DEV'}) { | |
114 | push (@graphs, ('BLUE')); } | |
115 | if ($netsettings{'ORANGE_DEV'}) { | |
116 | push (@graphs, ('ORANGE')); } | |
117 | push (@graphs, ("RED")); | |
118 | push (@graphs, ('gateway')); | |
119 | ||
120 | foreach my $graphname (@graphs) { | |
121 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); | |
122 | ||
123 | if (-e "$graphdir/${graphname}-day.png") { | |
124 | my $ftime = localtime((stat("$graphdir/${graphname}-day.png"))[9]); | |
125 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n"; | |
126 | print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>"; | |
127 | print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />"; | |
128 | print "</a>"; | |
129 | } else { | |
130 | print $Lang::tr{'no information available'}; | |
131 | } | |
132 | print "<br />\n"; | |
133 | &Header::closebox(); | |
134 | } | |
135 | } | |
136 | ||
137 | print "<div align='center'><table width='80%'><tr><td align='center'>"; | |
138 | if ( $cgigraphs[1] eq "cpu" || $cgigraphs[1] eq "load" ) { print "<a href='/cgi-bin/system.cgi'>"; } | |
139 | elsif ( $cgigraphs[1] eq "memory" || $cgigraphs[1] eq "swap" ) { print "<a href='/cgi-bin/memory.cgi'>"; } | |
140 | elsif ( $cgigraphs[1] eq "processes" ) { print "<a href='/cgi-bin/services.cgi'>"; } | |
141 | elsif ( $cgigraphs[1] =~ /disk/ ) { print "<a href='/cgi-bin/media.cgi'>"; } | |
142 | elsif ( $cgigraphs[1] =~ /red/ || $cgigraphs[1] =~ /ppp/ || $cgigraphs[1] =~ /ipsec/ ) { print "<a href='/cgi-bin/network.cgi?network=red'>"; } | |
143 | elsif ( $cgigraphs[1] =~ /green/ || $cgigraphs[1] =~ /blue/ || $cgigraphs[1] =~ /orange/ || $cgigraphs[1] =~ /wireless/ ) { print "<a href='/cgi-bin/network.cgi?network=internal'>"; } | |
144 | elsif ( $cgigraphs[1] eq "fwhits" || $cgigraphs[2] ne "" ) { print "<a href='/cgi-bin/network.cgi?network=other'>"; } | |
145 | print "$Lang::tr{'back'}</a></td></tr></table></div>\n"; | |
146 | ||
147 | &Header::closebigbox(); | |
148 | &Header::closepage(); |