]>
Commit | Line | Data |
---|---|---|
72fe12a9 | 1 | #!/usr/bin/perl |
70df8302 MT |
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 | ############################################################################### | |
72fe12a9 MT |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
72fe12a9 MT |
27 | |
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
350b52c5 | 31 | require "${General::swroot}/graphs.pl"; |
72fe12a9 MT |
32 | |
33 | my %cgiparams=(); | |
34 | my %pppsettings=(); | |
35 | my %netsettings=(); | |
36 | my @cgiparams=(); | |
37 | my @graphs=(); | |
246c0d71 | 38 | my @pings=(); |
dd8bfcf5 | 39 | my @wireless=(); |
72fe12a9 MT |
40 | my $iface=''; |
41 | my %dhcpsettings=(); | |
42 | my %dhcpinfo=(); | |
43 | my $output=''; | |
44 | ||
45 | &Header::showhttpheaders(); | |
46 | ||
47 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
48 | ||
49 | $ENV{'QUERY_STRING'} =~ s/&//g; | |
50 | @cgiparams = split(/network=/,$ENV{'QUERY_STRING'}); | |
51 | $cgiparams[1] = '' unless defined $cgiparams[1]; | |
52 | ||
53 | if ($cgiparams[1] =~ /red/) { | |
54 | &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, ''); | |
f5d339c8 AF |
55 | if ($netsettings{'RED_TYPE'} ne 'PPPOE') { |
56 | if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) { | |
57 | push (@graphs, ($netsettings{'RED_DEV'})); | |
58 | } | |
59 | } else { | |
60 | push (@graphs, "ppp0"); | |
61 | } | |
8fb804b5 | 62 | if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));} |
9061a365 | 63 | if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-tun0.rrd") {push (@graphs, ("tun0"));} |
a332b303 CS |
64 | }elsif ($cgiparams[1] =~ /other/) { |
65 | &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, ''); | |
246c0d71 CS |
66 | my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`; |
67 | foreach (@pinggraphs){ | |
68 | $_ =~ /(.*)\/ping\/ping-(.*)\.rrd/; | |
69 | push(@pings,$2); | |
70 | } | |
a332b303 | 71 | push (@graphs, ("fwhits")); |
dd8bfcf5 | 72 | |
a332b303 | 73 | }else { |
72fe12a9 | 74 | &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, ''); |
a332b303 | 75 | push (@graphs, ($netsettings{'GREEN_DEV'})); |
72fe12a9 | 76 | if ($netsettings{'BLUE_DEV'}) { |
a332b303 | 77 | push (@graphs, ($netsettings{'BLUE_DEV'})); } |
72fe12a9 | 78 | if ($netsettings{'ORANGE_DEV'}) { |
a332b303 | 79 | push (@graphs, ($netsettings{'ORANGE_DEV'})); } |
dd8bfcf5 CS |
80 | my @wirelessgraphs = `ls -dA /var/log/rrd/collectd/localhost/wireless*`; |
81 | foreach (@wirelessgraphs){ | |
82 | $_ =~ /(.*)\/wireless-(.*)/; | |
83 | push(@wireless,$2); | |
84 | } | |
72fe12a9 MT |
85 | } |
86 | ||
87 | &Header::openbigbox('100%', 'left'); | |
88 | ||
246c0d71 CS |
89 | foreach my $graphname (@pings) { |
90 | ||
91 | if ($graphname eq "gateway" ) | |
92 | { &Graphs::updatepinggraph("day","gateway"); } | |
93 | else | |
94 | { &Graphs::updatepinggraph("day","$graphname"); } | |
95 | ||
96 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); | |
97 | if (-e "$Header::graphdir/${graphname}-day.png") { | |
98 | my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]); | |
99 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n"; | |
100 | print "<a href='/cgi-bin/graphs.cgi?graph=$graphname&graph=ping'>"; | |
101 | print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />"; | |
102 | print "</a>"; | |
103 | } else { | |
104 | print $Lang::tr{'no information available'}; | |
105 | } | |
106 | print "<br />\n"; | |
107 | &Header::closebox(); | |
108 | } | |
109 | ||
72fe12a9 MT |
110 | foreach my $graphname (@graphs) { |
111 | ||
246c0d71 | 112 | if ($graphname eq "fwhits" ) |
a332b303 | 113 | { &Graphs::updatefwhitsgraph("day"); } |
350b52c5 | 114 | else |
b05768be | 115 | { &Graphs::updateifgraph($graphname, "day"); } |
dd8bfcf5 | 116 | |
72fe12a9 MT |
117 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); |
118 | if (-e "$Header::graphdir/${graphname}-day.png") { | |
119 | my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]); | |
120 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n"; | |
121 | print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>"; | |
122 | print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />"; | |
123 | print "</a>"; | |
124 | } else { | |
125 | print $Lang::tr{'no information available'}; | |
dd8bfcf5 CS |
126 | } |
127 | print "<br />\n"; | |
128 | &Header::closebox(); | |
129 | } | |
130 | ||
131 | foreach my $graphname (@wireless) { | |
132 | ||
133 | &Graphs::wireless("day",$graphname); | |
134 | ||
135 | &Header::openbox('100%', 'center', "wireless $graphname $Lang::tr{'graph'}"); | |
136 | if (-e "$Header::graphdir/wireless-${graphname}-day.png") { | |
137 | my $ftime = localtime((stat("$Header::graphdir/wireless-${graphname}-day.png"))[9]); | |
138 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n"; | |
139 | print "<a href='/cgi-bin/graphs.cgi?graph=wireless&graph=$graphname'>"; | |
140 | print "<img alt='' src='/graphs/wireless-${graphname}-day.png' border='0' />"; | |
141 | print "</a>"; | |
142 | } else { | |
143 | print $Lang::tr{'no information available'}; | |
72fe12a9 MT |
144 | } |
145 | print "<br />\n"; | |
146 | &Header::closebox(); | |
147 | } | |
148 | ||
149 | if ($cgiparams[1] =~ /red/) { | |
150 | ||
cb5e9c6c | 151 | if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") { |
72fe12a9 MT |
152 | |
153 | &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}"); | |
154 | if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") { | |
155 | ||
156 | &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo); | |
157 | ||
158 | my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`; | |
159 | my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`; | |
160 | ||
161 | my $lsetme=0; | |
162 | my $leasetime=""; | |
163 | if ($dhcpinfo{'LEASETIME'} ne "") { | |
164 | $lsetme=$dhcpinfo{'LEASETIME'}; | |
165 | $lsetme=($lsetme/60); | |
166 | if ($lsetme > 59) { | |
167 | $lsetme=($lsetme/60); $leasetime=$lsetme." Hour"; | |
168 | } else { | |
169 | $leasetime=$lsetme." Minute"; | |
170 | } | |
171 | if ($lsetme > 1) { | |
172 | $leasetime=$leasetime."s"; | |
173 | } | |
174 | } | |
175 | my $rentme=0; | |
176 | my $rnwltime=""; | |
177 | if ($dhcpinfo{'RENEWALTIME'} ne "") { | |
178 | $rentme=$dhcpinfo{'RENEWALTIME'}; | |
179 | $rentme=($rentme/60); | |
180 | if ($rentme > 59){ | |
181 | $rentme=($rentme/60); $rnwltime=$rentme." Hour"; | |
182 | } else { | |
183 | $rnwltime=$rentme." Minute"; | |
184 | } | |
185 | if ($rentme > 1){ | |
186 | $rnwltime=$rnwltime."s"; | |
187 | } | |
188 | } | |
189 | my $maxtme=0; | |
190 | my $maxtime=""; | |
191 | if ($dhcpinfo{'REBINDTIME'} ne "") { | |
192 | $maxtme=$dhcpinfo{'REBINDTIME'}; | |
193 | $maxtme=($maxtme/60); | |
194 | if ($maxtme > 59){ | |
195 | $maxtme=($maxtme/60); $maxtime=$maxtme." Hour"; | |
196 | } else { | |
197 | $maxtime=$maxtme." Minute"; | |
198 | } | |
199 | if ($maxtme > 1) { | |
200 | $maxtime=$maxtime."s"; | |
201 | } | |
202 | } | |
203 | ||
204 | print "<table width='100%'>"; | |
205 | if ($dhcpinfo{'HOSTNAME'}) { | |
206 | print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n"; | |
207 | } else { | |
208 | print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n"; | |
209 | } | |
210 | print <<END | |
211 | <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr> | |
212 | <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr> | |
213 | <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr> | |
214 | <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr> | |
215 | <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr> | |
216 | <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr> | |
217 | <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr> | |
218 | </table> | |
219 | END | |
220 | ; | |
221 | } | |
222 | else | |
223 | { | |
224 | print "$Lang::tr{'no dhcp lease'}"; | |
225 | } | |
226 | &Header::closebox(); | |
227 | } | |
228 | ||
229 | if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') { | |
230 | &Header::CheckSortOrder; | |
231 | &Header::PrintActualLeases; | |
232 | } | |
233 | ||
234 | } else { | |
235 | ||
236 | &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'}); | |
237 | $output = `/sbin/ip route show`; | |
238 | $output = &Header::cleanhtml($output,"y"); | |
239 | print "<pre>$output</pre>\n"; | |
240 | &Header::closebox(); | |
241 | ||
242 | &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'}); | |
243 | $output = `/sbin/ip neigh show`; | |
244 | $output = &Header::cleanhtml($output,"y"); | |
245 | print "<pre>$output</pre>\n"; | |
246 | &Header::closebox(); | |
247 | ||
248 | } | |
249 | ||
250 | &Header::closebigbox(); | |
251 | &Header::closepage(); |