ipsec: Drop delayed restart setting
[ipfire-2.x.git] / html / cgi-bin / traffic.cgi
CommitLineData
10a04d70 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
2b9b518a 5# Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
70df8302
MT
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###############################################################################
10a04d70
MT
21
22use strict;
23
24# enable only the following on debugging purpose
cb5e9c6c
CS
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
10a04d70
MT
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
10a04d70 31
f2fdd0c1
CS
32my %color = ();
33my %mainsettings = ();
34&General::readhash("${General::swroot}/main/settings", \%mainsettings);
35&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
36
d81292e0 37my %cgiparams;
10a04d70
MT
38my %pppsettings;
39my %netsettings;
40
41&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
42&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
43
10a04d70 44
10a04d70
MT
45&Header::getcgihash(\%cgiparams);
46
d81292e0 47&Header::showhttpheaders();
10a04d70 48&Header::openpage($Lang::tr{'sstraffic'}, 1, '');
10a04d70 49&Header::openbigbox('100%', 'left');
10a04d70 50
7b42e677 51&Header::openbox('100%', 'center', "$Lang::tr{'traffics'}");
10a04d70 52
6c33dc5c
AF
53# Display internal network
54display_vnstat($netsettings{'GREEN_DEV'});
10a04d70 55
6c33dc5c
AF
56# Display external network / check if it is PPP or ETH
57# and dont display if RED_DEV=GREEN_DEV (green only mode)
58if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
59 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) {
60 display_vnstat($netsettings{'RED_DEV'});
61 }
62} else {
63 display_vnstat("ppp0");
10a04d70
MT
64}
65
6c33dc5c
AF
66# Check config and display aditional Networks (BLUE and ORANGE)
67# if they exist
b05768be 68if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/) {
6c33dc5c 69 display_vnstat($netsettings{'BLUE_DEV'});
10a04d70
MT
70}
71
b05768be 72if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/) {
6c33dc5c 73 display_vnstat($netsettings{'ORANGE_DEV'});
d81292e0 74}
10a04d70
MT
75
76&Header::closebox();
10a04d70 77&Header::closebigbox();
10a04d70 78&Header::closepage();
6c33dc5c
AF
79
80sub display_vnstat
81{
82 my $device = $_[0];
83
da205291 84 my $testdata = `/usr/bin/vnstat -i $device`;
7b42e677 85
da205291
AF
86 if ( $testdata =~ 'enough') {
87 print"No data for $device !<br>";
88 } else {
2b9b518a 89 system("/usr/bin/vnstati -c 5 -s -i $device -o /srv/web/ipfire/html/graphs/vnstat-s-$device.png");
7b42e677
AF
90 # Hour graph
91 system("/usr/bin/vnstati -c 5 -h -i $device -o /srv/web/ipfire/html/graphs/vnstat-h-$device.png");
92 # Day graph
93 system("/usr/bin/vnstati -c 5 -d -i $device -o /srv/web/ipfire/html/graphs/vnstat-d-$device.png");
94 # Month graph
95 system("/usr/bin/vnstati -c 5 -m -i $device -o /srv/web/ipfire/html/graphs/vnstat-m-$device.png");
96 # Top10 graph
97 system("/usr/bin/vnstati -c 5 -t -i $device -o /srv/web/ipfire/html/graphs/vnstat-t-$device.png");
6c33dc5c
AF
98
99# Generate HTML-Table with the graphs
100print <<END
2b9b518a
AF
101<table>
102<tr><td><img src="/graphs/vnstat-s-$device.png"></td></tr>
6c33dc5c
AF
103<tr><td><img src="/graphs/vnstat-h-$device.png"></td></tr>
104<tr><td><img src="/graphs/vnstat-d-$device.png"></td></tr>
105<tr><td><img src="/graphs/vnstat-m-$device.png"></td></tr>
106<tr><td><img src="/graphs/vnstat-t-$device.png"></td></tr>
107</table>
108END
109;
7b42e677
AF
110 }
111 print"<hr>";
6c33dc5c 112}