]>
git.ipfire.org Git - 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";
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 push (@graphs, ($netsettings{'RED_DEV'}));
55 if (-e
"/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
56 }elsif ($cgiparams[1] =~ /other/) {
57 &Header
::openpage
($Lang::tr
{'network traffic graphs others'}, 1, '');
58 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
59 foreach (@pinggraphs){
60 $_ =~ /(.*)\/ping\
/ping-(.*)\.rrd/;
63 push (@graphs, ("fwhits"));
65 &Header
::openpage
($Lang::tr
{'network traffic graphs internal'}, 1, '');
66 push (@graphs, ($netsettings{'GREEN_DEV'}));
67 if ($netsettings{'BLUE_DEV'}) {
68 push (@graphs, ($netsettings{'BLUE_DEV'})); }
69 if ($netsettings{'ORANGE_DEV'}) {
70 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
73 &Header
::openbigbox
('100%', 'left');
75 foreach my $graphname (@pings) {
77 if ($graphname eq "gateway" )
78 { &Graphs
::updatepinggraph
("day","gateway"); }
80 { &Graphs
::updatepinggraph
("day","$graphname"); }
82 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
83 if (-e
"$Header::graphdir/${graphname}-day.png") {
84 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
85 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
86 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname&graph=ping'>";
87 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
90 print $Lang::tr
{'no information available'};
96 foreach my $graphname (@graphs) {
98 if ($graphname eq "fwhits" )
99 { &Graphs
::updatefwhitsgraph
("day"); }
101 { &Graphs
::updateifgraph
($graphname, "day"); }
103 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
104 if (-e
"$Header::graphdir/${graphname}-day.png") {
105 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
106 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
107 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
108 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
111 print $Lang::tr
{'no information available'};
117 if ($cgiparams[1] =~ /red/) {
119 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
121 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
122 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
124 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
126 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
127 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
131 if ($dhcpinfo{'LEASETIME'} ne "") {
132 $lsetme=$dhcpinfo{'LEASETIME'};
133 $lsetme=($lsetme/60);
135 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
137 $leasetime=$lsetme." Minute";
140 $leasetime=$leasetime."s";
145 if ($dhcpinfo{'RENEWALTIME'} ne "") {
146 $rentme=$dhcpinfo{'RENEWALTIME'};
147 $rentme=($rentme/60);
149 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
151 $rnwltime=$rentme." Minute";
154 $rnwltime=$rnwltime."s";
159 if ($dhcpinfo{'REBINDTIME'} ne "") {
160 $maxtme=$dhcpinfo{'REBINDTIME'};
161 $maxtme=($maxtme/60);
163 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
165 $maxtime=$maxtme." Minute";
168 $maxtime=$maxtime."s";
172 print "<table width='100%'>";
173 if ($dhcpinfo{'HOSTNAME'}) {
174 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
176 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
179 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
180 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
181 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
182 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
183 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
184 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
185 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
192 print "$Lang::tr{'no dhcp lease'}";
197 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
198 &Header
::CheckSortOrder
;
199 &Header
::PrintActualLeases
;
204 &Header
::openbox
('100%', 'left', $Lang::tr
{'routing table entries'});
205 $output = `/sbin/ip route show`;
206 $output = &Header
::cleanhtml
($output,"y");
207 print "<pre>$output</pre>\n";
210 &Header
::openbox
('100%', 'left', $Lang::tr
{'arp table entries'});
211 $output = `/sbin/ip neigh show`;
212 $output = &Header
::cleanhtml
($output,"y");
213 print "<pre>$output</pre>\n";
218 &Header
::closebigbox
();
219 &Header
::closepage
();