]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/network.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
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";
45 &Header
::showhttpheaders
();
47 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
49 $ENV{'QUERY_STRING'} =~ s/&//g;
50 @cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
51 $cgiparams[1] = '' unless defined $cgiparams[1];
53 if ($cgiparams[1] =~ /red/) {
54 &Header
::openpage
($Lang::tr
{'network traffic graphs external'}, 1, '');
55 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
56 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) {
57 push (@graphs, ($netsettings{'RED_DEV'}));
60 push (@graphs, "ppp0");
62 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
63 }elsif ($cgiparams[1] =~ /other/) {
64 &Header
::openpage
($Lang::tr
{'network traffic graphs others'}, 1, '');
65 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
66 foreach (@pinggraphs){
67 $_ =~ /(.*)\/ping\
/ping-(.*)\.rrd/;
70 push (@graphs, ("fwhits"));
73 &Header
::openpage
($Lang::tr
{'network traffic graphs internal'}, 1, '');
74 push (@graphs, ($netsettings{'GREEN_DEV'}));
75 if ($netsettings{'BLUE_DEV'}) {
76 push (@graphs, ($netsettings{'BLUE_DEV'})); }
77 if ($netsettings{'ORANGE_DEV'}) {
78 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
79 my @wirelessgraphs = `ls -dA /var/log/rrd/collectd/localhost/wireless*`;
80 foreach (@wirelessgraphs){
81 $_ =~ /(.*)\/wireless
-(.*)/;
86 &Header
::openbigbox
('100%', 'left');
88 foreach my $graphname (@pings) {
90 if ($graphname eq "gateway" )
91 { &Graphs
::updatepinggraph
("day","gateway"); }
93 { &Graphs
::updatepinggraph
("day","$graphname"); }
95 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
96 if (-e
"$Header::graphdir/${graphname}-day.png") {
97 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
98 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
99 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname&graph=ping'>";
100 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
103 print $Lang::tr
{'no information available'};
109 foreach my $graphname (@graphs) {
111 if ($graphname eq "fwhits" )
112 { &Graphs
::updatefwhitsgraph
("day"); }
114 { &Graphs
::updateifgraph
($graphname, "day"); }
116 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
117 if (-e
"$Header::graphdir/${graphname}-day.png") {
118 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
119 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
120 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
121 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
124 print $Lang::tr
{'no information available'};
130 foreach my $graphname (@wireless) {
132 &Graphs
::wireless
("day",$graphname);
134 &Header
::openbox
('100%', 'center', "wireless $graphname $Lang::tr{'graph'}");
135 if (-e
"$Header::graphdir/wireless-${graphname}-day.png") {
136 my $ftime = localtime((stat("$Header::graphdir/wireless-${graphname}-day.png"))[9]);
137 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
138 print "<a href='/cgi-bin/graphs.cgi?graph=wireless&graph=$graphname'>";
139 print "<img alt='' src='/graphs/wireless-${graphname}-day.png' border='0' />";
142 print $Lang::tr
{'no information available'};
148 if ($cgiparams[1] =~ /red/) {
150 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
152 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
153 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
155 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
157 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
158 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
162 if ($dhcpinfo{'LEASETIME'} ne "") {
163 $lsetme=$dhcpinfo{'LEASETIME'};
164 $lsetme=($lsetme/60);
166 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
168 $leasetime=$lsetme." Minute";
171 $leasetime=$leasetime."s";
176 if ($dhcpinfo{'RENEWALTIME'} ne "") {
177 $rentme=$dhcpinfo{'RENEWALTIME'};
178 $rentme=($rentme/60);
180 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
182 $rnwltime=$rentme." Minute";
185 $rnwltime=$rnwltime."s";
190 if ($dhcpinfo{'REBINDTIME'} ne "") {
191 $maxtme=$dhcpinfo{'REBINDTIME'};
192 $maxtme=($maxtme/60);
194 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
196 $maxtime=$maxtme." Minute";
199 $maxtime=$maxtime."s";
203 print "<table width='100%'>";
204 if ($dhcpinfo{'HOSTNAME'}) {
205 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
207 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
210 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
211 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
212 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
213 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
214 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
215 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
216 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
223 print "$Lang::tr{'no dhcp lease'}";
228 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
229 &Header
::CheckSortOrder
;
230 &Header
::PrintActualLeases
;
235 &Header
::openbox
('100%', 'left', $Lang::tr
{'routing table entries'});
236 $output = `/sbin/ip route show`;
237 $output = &Header
::cleanhtml
($output,"y");
238 print "<pre>$output</pre>\n";
241 &Header
::openbox
('100%', 'left', $Lang::tr
{'arp table entries'});
242 $output = `/sbin/ip neigh show`;
243 $output = &Header
::cleanhtml
($output,"y");
244 print "<pre>$output</pre>\n";
249 &Header
::closebigbox
();
250 &Header
::closepage
();