]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame_incremental - html/cgi-bin/network.cgi
makegraphs umgebaut, sodass nurnoch rrd daten geschrieben werden die graphen
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / network.cgi
... / ...
CommitLineData
1#!/usr/bin/perl
2#
3# SmoothWall CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The SmoothWall Team
8#
9#
10
11use strict;
12
13# enable only the following on debugging purpose
14use warnings;
15use CGI::Carp 'fatalsToBrowser';
16
17require '/var/ipfire/general-functions.pl';
18require "${General::swroot}/lang.pl";
19require "${General::swroot}/header.pl";
20require "${General::swroot}/graphs.pl";
21
22my %cgiparams=();
23my %pppsettings=();
24my %netsettings=();
25my @cgiparams=();
26my @graphs=();
27my $iface='';
28my %dhcpsettings=();
29my %dhcpinfo=();
30my $output='';
31
32&Header::showhttpheaders();
33
34&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
35
36$ENV{'QUERY_STRING'} =~ s/&//g;
37@cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
38$cgiparams[1] = '' unless defined $cgiparams[1];
39
40if ($cgiparams[1] =~ /red/) {
41 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
42 push (@graphs, ("RED"));
43 push (@graphs, ('lq'));
44} else {
45 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
46 push (@graphs, ('GREEN'));
47 if ($netsettings{'BLUE_DEV'}) {
48 push (@graphs, ('BLUE')); }
49 if ($netsettings{'ORANGE_DEV'}) {
50 push (@graphs, ('ORANGE')); }
51}
52
53&Header::openbigbox('100%', 'left');
54
55foreach my $graphname (@graphs) {
56
57 if ($graphname == "lq" )
58 {
59 &Graphs::updatelqgraph("day");
60 &Graphs::updatelqgraph("week");
61 &Graphs::updatelqgraph("month");
62 &Graphs::updatelqgraph("year");
63 }
64 else
65 {
66 &Graphs::updateifgraph ($graphname, "day");
67 &Graphs::updateifgraph ($graphname, "week");
68 &Graphs::updateifgraph ($graphname, "month");
69 &Graphs::updateifgraph ($graphname, "year");
70 }
71
72 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
73 if (-e "$Header::graphdir/${graphname}-day.png") {
74 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
75 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
76 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
77 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
78 print "</a>";
79 } else {
80 print $Lang::tr{'no information available'};
81 }
82 print "<br />\n";
83 &Header::closebox();
84}
85
86if ($cgiparams[1] =~ /red/) {
87
88 if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
89
90 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
91 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
92
93 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
94
95 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
96 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
97
98 my $lsetme=0;
99 my $leasetime="";
100 if ($dhcpinfo{'LEASETIME'} ne "") {
101 $lsetme=$dhcpinfo{'LEASETIME'};
102 $lsetme=($lsetme/60);
103 if ($lsetme > 59) {
104 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
105 } else {
106 $leasetime=$lsetme." Minute";
107 }
108 if ($lsetme > 1) {
109 $leasetime=$leasetime."s";
110 }
111 }
112 my $rentme=0;
113 my $rnwltime="";
114 if ($dhcpinfo{'RENEWALTIME'} ne "") {
115 $rentme=$dhcpinfo{'RENEWALTIME'};
116 $rentme=($rentme/60);
117 if ($rentme > 59){
118 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
119 } else {
120 $rnwltime=$rentme." Minute";
121 }
122 if ($rentme > 1){
123 $rnwltime=$rnwltime."s";
124 }
125 }
126 my $maxtme=0;
127 my $maxtime="";
128 if ($dhcpinfo{'REBINDTIME'} ne "") {
129 $maxtme=$dhcpinfo{'REBINDTIME'};
130 $maxtme=($maxtme/60);
131 if ($maxtme > 59){
132 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
133 } else {
134 $maxtime=$maxtme." Minute";
135 }
136 if ($maxtme > 1) {
137 $maxtime=$maxtime."s";
138 }
139 }
140
141 print "<table width='100%'>";
142 if ($dhcpinfo{'HOSTNAME'}) {
143 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
144 } else {
145 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
146 }
147 print <<END
148 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
149 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
150 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
151 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
152 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
153 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
154 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
155 </table>
156END
157 ;
158 }
159 else
160 {
161 print "$Lang::tr{'no dhcp lease'}";
162 }
163 &Header::closebox();
164 }
165
166 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
167 &Header::CheckSortOrder;
168 &Header::PrintActualLeases;
169 }
170
171} else {
172
173 &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
174 $output = `/sbin/ip route show`;
175 $output = &Header::cleanhtml($output,"y");
176 print "<pre>$output</pre>\n";
177 &Header::closebox();
178
179 &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
180 $output = `/sbin/ip neigh show`;
181 $output = &Header::cleanhtml($output,"y");
182 print "<pre>$output</pre>\n";
183 &Header::closebox();
184
185}
186
187&Header::closebigbox();
188&Header::closepage();