From da205291639582f64726659fc47767c6c9f683f2 Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Mon, 26 May 2008 23:10:15 +0200 Subject: [PATCH] Workaround a bug in vnstati if vnstat give nan% --- html/cgi-bin/traffic.cgi | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/html/cgi-bin/traffic.cgi b/html/cgi-bin/traffic.cgi index 0fff97ca89..70e5726c90 100644 --- a/html/cgi-bin/traffic.cgi +++ b/html/cgi-bin/traffic.cgi @@ -83,10 +83,15 @@ sub display_vnstat { my $device = $_[0]; - my $testdata = `/usr/bin/vnstat -i $device | grep "enough data"`; + my $testdata = `/usr/bin/vnstat -i $device`; - if (! $testdata) { - system("/usr/bin/vnstati -c 5 -s -i $device -o /srv/web/ipfire/html/graphs/vnstat-s-$device.png"); + if ( $testdata =~ 'enough') { + print"No data for $device !
"; + } else { + # Falls back to textoutput if there was no % value because vnstati hang in this case + if (!($testdata =~ 'nan%')) { + 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 @@ -97,9 +102,15 @@ sub display_vnstat 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 ""; + if ($testdata =~ 'nan%') { + print ""; + } else { + print""; + } print < - @@ -107,8 +118,6 @@ print < END ; - } else { - print"No data for $device !
"; } print"
"; } -- 2.39.2
";
+		system("/usr/bin/vnstat -i $device");
+		print "