]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/network.cgi
Added qos.sh to backup include
[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=();
dd8bfcf5 39my @wireless=();
72fe12a9
MT
40my $iface='';
41my %dhcpsettings=();
42my %dhcpinfo=();
43my $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
53if ($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"));}
a332b303
CS
63}elsif ($cgiparams[1] =~ /other/) {
64 &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, '');
246c0d71
CS
65 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
66 foreach (@pinggraphs){
67 $_ =~ /(.*)\/ping\/ping-(.*)\.rrd/;
68 push(@pings,$2);
69 }
a332b303 70 push (@graphs, ("fwhits"));
dd8bfcf5 71
a332b303 72}else {
72fe12a9 73 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
a332b303 74 push (@graphs, ($netsettings{'GREEN_DEV'}));
72fe12a9 75 if ($netsettings{'BLUE_DEV'}) {
a332b303 76 push (@graphs, ($netsettings{'BLUE_DEV'})); }
72fe12a9 77 if ($netsettings{'ORANGE_DEV'}) {
a332b303 78 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
dd8bfcf5
CS
79 my @wirelessgraphs = `ls -dA /var/log/rrd/collectd/localhost/wireless*`;
80 foreach (@wirelessgraphs){
81 $_ =~ /(.*)\/wireless-(.*)/;
82 push(@wireless,$2);
83 }
72fe12a9
MT
84}
85
86&Header::openbigbox('100%', 'left');
87
246c0d71
CS
88foreach my $graphname (@pings) {
89
90 if ($graphname eq "gateway" )
91 { &Graphs::updatepinggraph("day","gateway"); }
92 else
93 { &Graphs::updatepinggraph("day","$graphname"); }
94
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' />";
101 print "</a>";
102 } else {
103 print $Lang::tr{'no information available'};
104 }
105 print "<br />\n";
106 &Header::closebox();
107}
108
72fe12a9
MT
109foreach my $graphname (@graphs) {
110
246c0d71 111 if ($graphname eq "fwhits" )
a332b303 112 { &Graphs::updatefwhitsgraph("day"); }
350b52c5 113 else
b05768be 114 { &Graphs::updateifgraph($graphname, "day"); }
dd8bfcf5 115
72fe12a9
MT
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' />";
122 print "</a>";
123 } else {
124 print $Lang::tr{'no information available'};
dd8bfcf5
CS
125 }
126 print "<br />\n";
127 &Header::closebox();
128}
129
130foreach my $graphname (@wireless) {
131
132 &Graphs::wireless("day",$graphname);
133
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' />";
140 print "</a>";
141 } else {
142 print $Lang::tr{'no information available'};
72fe12a9
MT
143 }
144 print "<br />\n";
145 &Header::closebox();
146}
147
148if ($cgiparams[1] =~ /red/) {
149
cb5e9c6c 150 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
72fe12a9
MT
151
152 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
153 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
154
155 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
156
157 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
158 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
159
160 my $lsetme=0;
161 my $leasetime="";
162 if ($dhcpinfo{'LEASETIME'} ne "") {
163 $lsetme=$dhcpinfo{'LEASETIME'};
164 $lsetme=($lsetme/60);
165 if ($lsetme > 59) {
166 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
167 } else {
168 $leasetime=$lsetme." Minute";
169 }
170 if ($lsetme > 1) {
171 $leasetime=$leasetime."s";
172 }
173 }
174 my $rentme=0;
175 my $rnwltime="";
176 if ($dhcpinfo{'RENEWALTIME'} ne "") {
177 $rentme=$dhcpinfo{'RENEWALTIME'};
178 $rentme=($rentme/60);
179 if ($rentme > 59){
180 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
181 } else {
182 $rnwltime=$rentme." Minute";
183 }
184 if ($rentme > 1){
185 $rnwltime=$rnwltime."s";
186 }
187 }
188 my $maxtme=0;
189 my $maxtime="";
190 if ($dhcpinfo{'REBINDTIME'} ne "") {
191 $maxtme=$dhcpinfo{'REBINDTIME'};
192 $maxtme=($maxtme/60);
193 if ($maxtme > 59){
194 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
195 } else {
196 $maxtime=$maxtme." Minute";
197 }
198 if ($maxtme > 1) {
199 $maxtime=$maxtime."s";
200 }
201 }
202
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";
206 } else {
207 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
208 }
209 print <<END
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>
217 </table>
218END
219 ;
220 }
221 else
222 {
223 print "$Lang::tr{'no dhcp lease'}";
224 }
225 &Header::closebox();
226 }
227
228 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
229 &Header::CheckSortOrder;
230 &Header::PrintActualLeases;
231 }
232
233} else {
234
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";
239 &Header::closebox();
240
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";
245 &Header::closebox();
246
247}
248
249&Header::closebigbox();
250&Header::closepage();