]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/network.cgi
Removed "mbmon Graphs" from credits
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / network.cgi
CommitLineData
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
22use strict;
23
24# enable only the following on debugging purpose
cb5e9c6c
CS
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
72fe12a9
MT
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
350b52c5 31require "${General::swroot}/graphs.pl";
72fe12a9
MT
32
33my %cgiparams=();
34my %pppsettings=();
35my %netsettings=();
36my @cgiparams=();
37my @graphs=();
246c0d71 38my @pings=();
72fe12a9
MT
39my $iface='';
40my %dhcpsettings=();
41my %dhcpinfo=();
42my $output='';
43
44&Header::showhttpheaders();
45
46&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
47
48$ENV{'QUERY_STRING'} =~ s/&//g;
49@cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
50$cgiparams[1] = '' unless defined $cgiparams[1];
51
52if ($cgiparams[1] =~ /red/) {
53 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
f5d339c8
AF
54 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
55 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) {
56 push (@graphs, ($netsettings{'RED_DEV'}));
57 }
58 } else {
59 push (@graphs, "ppp0");
60 }
8fb804b5 61 if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
a332b303
CS
62}elsif ($cgiparams[1] =~ /other/) {
63 &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, '');
246c0d71
CS
64 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
65 foreach (@pinggraphs){
66 $_ =~ /(.*)\/ping\/ping-(.*)\.rrd/;
67 push(@pings,$2);
68 }
a332b303
CS
69 push (@graphs, ("fwhits"));
70}else {
72fe12a9 71 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
a332b303 72 push (@graphs, ($netsettings{'GREEN_DEV'}));
72fe12a9 73 if ($netsettings{'BLUE_DEV'}) {
a332b303 74 push (@graphs, ($netsettings{'BLUE_DEV'})); }
72fe12a9 75 if ($netsettings{'ORANGE_DEV'}) {
a332b303 76 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
72fe12a9
MT
77}
78
79&Header::openbigbox('100%', 'left');
80
246c0d71
CS
81foreach my $graphname (@pings) {
82
83 if ($graphname eq "gateway" )
84 { &Graphs::updatepinggraph("day","gateway"); }
85 else
86 { &Graphs::updatepinggraph("day","$graphname"); }
87
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' />";
94 print "</a>";
95 } else {
96 print $Lang::tr{'no information available'};
97 }
98 print "<br />\n";
99 &Header::closebox();
100}
101
72fe12a9
MT
102foreach my $graphname (@graphs) {
103
246c0d71 104 if ($graphname eq "fwhits" )
a332b303 105 { &Graphs::updatefwhitsgraph("day"); }
350b52c5 106 else
b05768be 107 { &Graphs::updateifgraph($graphname, "day"); }
350b52c5 108
72fe12a9
MT
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' />";
115 print "</a>";
116 } else {
117 print $Lang::tr{'no information available'};
118 }
119 print "<br />\n";
120 &Header::closebox();
121}
122
123if ($cgiparams[1] =~ /red/) {
124
cb5e9c6c 125 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
72fe12a9
MT
126
127 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
128 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
129
130 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
131
132 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
133 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
134
135 my $lsetme=0;
136 my $leasetime="";
137 if ($dhcpinfo{'LEASETIME'} ne "") {
138 $lsetme=$dhcpinfo{'LEASETIME'};
139 $lsetme=($lsetme/60);
140 if ($lsetme > 59) {
141 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
142 } else {
143 $leasetime=$lsetme." Minute";
144 }
145 if ($lsetme > 1) {
146 $leasetime=$leasetime."s";
147 }
148 }
149 my $rentme=0;
150 my $rnwltime="";
151 if ($dhcpinfo{'RENEWALTIME'} ne "") {
152 $rentme=$dhcpinfo{'RENEWALTIME'};
153 $rentme=($rentme/60);
154 if ($rentme > 59){
155 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
156 } else {
157 $rnwltime=$rentme." Minute";
158 }
159 if ($rentme > 1){
160 $rnwltime=$rnwltime."s";
161 }
162 }
163 my $maxtme=0;
164 my $maxtime="";
165 if ($dhcpinfo{'REBINDTIME'} ne "") {
166 $maxtme=$dhcpinfo{'REBINDTIME'};
167 $maxtme=($maxtme/60);
168 if ($maxtme > 59){
169 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
170 } else {
171 $maxtime=$maxtme." Minute";
172 }
173 if ($maxtme > 1) {
174 $maxtime=$maxtime."s";
175 }
176 }
177
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";
181 } else {
182 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
183 }
184 print <<END
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>
192 </table>
193END
194 ;
195 }
196 else
197 {
198 print "$Lang::tr{'no dhcp lease'}";
199 }
200 &Header::closebox();
201 }
202
203 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
204 &Header::CheckSortOrder;
205 &Header::PrintActualLeases;
206 }
207
208} else {
209
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";
214 &Header::closebox();
215
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";
220 &Header::closebox();
221
222}
223
224&Header::closebigbox();
225&Header::closepage();