- # 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 {
+ # 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
+ 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");