]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/network.cgi
1c34ca769697828c35da450ab724853e0089e1ea
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";
44 &Header
::showhttpheaders
();
46 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
48 $ENV{'QUERY_STRING'} =~ s/&//g;
49 @cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
50 $cgiparams[1] = '' unless defined $cgiparams[1];
52 if ($cgiparams[1] =~ /red/) {
53 &Header
::openpage
($Lang::tr
{'network traffic graphs external'}, 1, '');
54 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
55 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) {
56 push (@graphs, ($netsettings{'RED_DEV'}));
59 push (@graphs, "ppp0");
61 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
62 }elsif ($cgiparams[1] =~ /other/) {
63 &Header
::openpage
($Lang::tr
{'network traffic graphs others'}, 1, '');
64 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
65 foreach (@pinggraphs){
66 $_ =~ /(.*)\/ping\
/ping-(.*)\.rrd/;
69 push (@graphs, ("fwhits"));
71 &Header
::openpage
($Lang::tr
{'network traffic graphs internal'}, 1, '');
72 push (@graphs, ($netsettings{'GREEN_DEV'}));
73 if ($netsettings{'BLUE_DEV'}) {
74 push (@graphs, ($netsettings{'BLUE_DEV'})); }
75 if ($netsettings{'ORANGE_DEV'}) {
76 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
79 &Header
::openbigbox
('100%', 'left');
81 foreach my $graphname (@pings) {
83 if ($graphname eq "gateway" )
84 { &Graphs
::updatepinggraph
("day","gateway"); }
86 { &Graphs
::updatepinggraph
("day","$graphname"); }
88 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
89 if (-e
"$Header::graphdir/${graphname}-day.png") {
90 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
91 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
92 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname&graph=ping'>";
93 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
96 print $Lang::tr
{'no information available'};
102 foreach my $graphname (@graphs) {
104 if ($graphname eq "fwhits" )
105 { &Graphs
::updatefwhitsgraph
("day"); }
107 { &Graphs
::updateifgraph
($graphname, "day"); }
109 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
110 if (-e
"$Header::graphdir/${graphname}-day.png") {
111 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
112 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
113 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
114 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
117 print $Lang::tr
{'no information available'};
123 if ($cgiparams[1] =~ /red/) {
125 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
127 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
128 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
130 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
132 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
133 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
137 if ($dhcpinfo{'LEASETIME'} ne "") {
138 $lsetme=$dhcpinfo{'LEASETIME'};
139 $lsetme=($lsetme/60);
141 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
143 $leasetime=$lsetme." Minute";
146 $leasetime=$leasetime."s";
151 if ($dhcpinfo{'RENEWALTIME'} ne "") {
152 $rentme=$dhcpinfo{'RENEWALTIME'};
153 $rentme=($rentme/60);
155 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
157 $rnwltime=$rentme." Minute";
160 $rnwltime=$rnwltime."s";
165 if ($dhcpinfo{'REBINDTIME'} ne "") {
166 $maxtme=$dhcpinfo{'REBINDTIME'};
167 $maxtme=($maxtme/60);
169 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
171 $maxtime=$maxtme." Minute";
174 $maxtime=$maxtime."s";
178 print "<table width='100%'>";
179 if ($dhcpinfo{'HOSTNAME'}) {
180 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
182 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
185 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
186 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
187 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
188 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
189 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
190 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
191 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
198 print "$Lang::tr{'no dhcp lease'}";
203 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
204 &Header
::CheckSortOrder
;
205 &Header
::PrintActualLeases
;
210 &Header
::openbox
('100%', 'left', $Lang::tr
{'routing table entries'});
211 $output = `/sbin/ip route show`;
212 $output = &Header
::cleanhtml
($output,"y");
213 print "<pre>$output</pre>\n";
216 &Header
::openbox
('100%', 'left', $Lang::tr
{'arp table entries'});
217 $output = `/sbin/ip neigh show`;
218 $output = &Header
::cleanhtml
($output,"y");
219 print "<pre>$output</pre>\n";
224 &Header
::closebigbox
();
225 &Header
::closepage
();