]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/traffic.cgi
Merge remote-tracking branch 'ms/dns-forwarding' into next
[ipfire-2.x.git] / html / cgi-bin / traffic.cgi
index 0930fdf40d0d73dc758c4952b7d044257a04e5cf..fbffecb7cc2082138ff43844dd2c5b71c6715fac 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+# Copyright (C) 2007-2014  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -28,8 +28,6 @@ use strict;
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
-require "${General::swroot}/net-traffic/net-traffic-admin.pl";
-require "${General::swroot}/net-traffic/net-traffic-lib.pl";
 
 my %color = ();
 my %mainsettings = ();
@@ -50,7 +48,7 @@ my %netsettings;
 &Header::openpage($Lang::tr{'sstraffic'}, 1, '');
 &Header::openbigbox('100%', 'left');
 
-&Header::openbox('100%', 'left', "$Lang::tr{'traffics'}");
+&Header::openbox('100%', 'center', "$Lang::tr{'traffics'}");
 
 # Display internal network
 display_vnstat($netsettings{'GREEN_DEV'});
@@ -83,23 +81,25 @@ sub display_vnstat
 {
        my $device = $_[0];
 
-       # Sumary graph sometimes hang so i print the text
-       print "<B><PRE>";
-       system("/usr/bin/vnstat -s -i $device");
-       print "</PRE></B>";
-       # generate Graphs if they are older than 5 min (-c 5)
-       # Hour graph
-       system("/usr/bin/vnstati -c 5 -h -i $device -o /srv/web/ipfire/html/graphs/vnstat-h-$device.png");
-       # Day graph
-       system("/usr/bin/vnstati -c 5 -d -i $device -o /srv/web/ipfire/html/graphs/vnstat-d-$device.png");
-       # Month graph
-       system("/usr/bin/vnstati -c 5 -m -i $device -o /srv/web/ipfire/html/graphs/vnstat-m-$device.png");
-       # Top10 graph
-       system("/usr/bin/vnstati -c 5 -t -i $device -o /srv/web/ipfire/html/graphs/vnstat-t-$device.png");
+       my $testdata = `/usr/bin/vnstat -i $device`;
+
+       if ( $testdata =~ 'enough') {
+               print"No data for $device !<br>";
+       } else {
+           system("/usr/bin/vnstati -c 5 -s -i $device -o /srv/web/ipfire/html/graphs/vnstat-s-$device.png");
+           # Hour graph
+           system("/usr/bin/vnstati -c 5 -h -i $device -o /srv/web/ipfire/html/graphs/vnstat-h-$device.png");
+           # Day graph
+           system("/usr/bin/vnstati -c 5 -d -i $device -o /srv/web/ipfire/html/graphs/vnstat-d-$device.png");
+           # Month graph
+           system("/usr/bin/vnstati -c 5 -m -i $device -o /srv/web/ipfire/html/graphs/vnstat-m-$device.png");
+           # Top10 graph
+           system("/usr/bin/vnstati -c 5 -t -i $device -o /srv/web/ipfire/html/graphs/vnstat-t-$device.png");
 
 # Generate HTML-Table with the graphs
 print <<END
 <table>
+<tr><td><img src="/graphs/vnstat-s-$device.png"></td></tr>
 <tr><td><img src="/graphs/vnstat-h-$device.png"></td></tr>
 <tr><td><img src="/graphs/vnstat-d-$device.png"></td></tr>
 <tr><td><img src="/graphs/vnstat-m-$device.png"></td></tr>
@@ -107,4 +107,6 @@ print <<END
 </table>
 END
 ;
+           }
+       print"<hr>";
 }