]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/traffic.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
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";
33 my %mainsettings = ();
34 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
35 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
41 &General
::readhash
("${General::swroot}/ppp/settings", \
%pppsettings);
42 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
45 &Header
::getcgihash
(\
%cgiparams);
47 &Header
::showhttpheaders
();
48 &Header
::openpage
($Lang::tr
{'sstraffic'}, 1, '');
49 &Header
::openbigbox
('100%', 'left');
51 &Header
::openbox
('100%', 'center', "$Lang::tr{'traffics'}");
53 # Display internal network
54 display_vnstat
($netsettings{'GREEN_DEV'});
56 # Display external network / check if it is PPP or ETH
57 # and dont display if RED_DEV=GREEN_DEV (green only mode)
58 if ($netsettings{'RED_TYPE'} ne 'PPPOE') {
59 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) {
60 display_vnstat
($netsettings{'RED_DEV'});
63 display_vnstat
("ppp0");
66 # Check config and display aditional Networks (BLUE and ORANGE)
68 if ($netsettings{'CONFIG_TYPE'} =~ /^(3|4)$/) {
69 display_vnstat
($netsettings{'BLUE_DEV'});
72 if ($netsettings{'CONFIG_TYPE'} =~ /^(2|4)$/) {
73 display_vnstat
($netsettings{'ORANGE_DEV'});
77 &Header
::closebigbox
();
84 my $testdata = `/usr/bin/vnstat -i $device`;
86 if ( $testdata =~ 'enough') {
87 print"No data for $device !<br>";
89 system("/usr/bin/vnstati -c 1 -s -i $device -o /srv/web/ipfire/html/graphs/vnstat-s-$device.png");
91 system("/usr/bin/vnstati -c 1 -h -i $device -o /srv/web/ipfire/html/graphs/vnstat-h-$device.png");
93 system("/usr/bin/vnstati -c 1 -d -i $device -o /srv/web/ipfire/html/graphs/vnstat-d-$device.png");
95 system("/usr/bin/vnstati -c 1 -m -i $device -o /srv/web/ipfire/html/graphs/vnstat-m-$device.png");
97 system("/usr/bin/vnstati -c 1 -t -i $device -o /srv/web/ipfire/html/graphs/vnstat-t-$device.png");
99 # Generate HTML-Table with the graphs
102 <tr><td><img src="/graphs/vnstat-s-$device.png"></td></tr>
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>