0

I'm trying to graph the cummulative bandwidth on an interface using Munin.

Apparently there is a bandwidth_ plugin for this (see http://munin-monitoring.org/browser/munin-contrib/plugins/network/bandwidth_), which I installed and is running since a few weeks now.

I was expecting to see some nice graphs, but everything is set to '0'.

When doing a munin-run, I get null values as well:

# munin-run bandwidth_br0
average.value  0
monthly.value 0
30dayusage.value  0

So I tried to have a look what the code says:

open( my $rx, "<", "/sys/class/net/$interface/statistics/rx_bytes" )
     || die "Unable to read: $!";
$counter_input = <$rx>;
chomp $counter_input;

... and that outputs an ever increasing value like it should:

# cat /sys/class/net/br0/statistics/rx_bytes
2095478809

My state file contains following info:

pst0^D^H^H12345678^D^H^H^H^C+
^@^@^D^C^B^@^@^@^H<80>^E^@^@^@input^H<80>^F^@^@^@output
^@^@^@1398125584^D^C^B^@^@^@^H<80>^E^@^@^@input^H<80>^F^@^@^@output
^@^@^@1398037387^D^C^B^@^@^@^H<80>^E^@^@^@input^H<80>^F^@^@^@output
^@^@^@1398331077^D^C^B^@^@^@^H<80>^E^@^@^@input^H<80>^F^@^@^@output
^@^@^@1397950990^D^C^B^@^@^@^H<80>^E^@^@^@input^H<80>^F^@^@^@output

Would anyone know where the issue lays or how to debug this further?

Using munin 2.0.17 on Ubuntu Saucy.

SaeX
  • 185
  • 8

2 Answers2

3

I wrote the plugin.

Here is a script I use to dump out the contents of the store file. I'm also interested in knowing if the self discovery identified the correct interface for you.

#!/usr/bin/perl

use Storable;
use Data::Dumper;
my $file="/var/lib/munin-node/plugin-state/nobody/bandwidth_eth1.state";
my $dump;
my $perf_ref;



my $store_ref = retrieve($file);
while (my ($key, $value) = each(%$store_ref) ) {
    $perf_ref->{$key} = $value;
}

foreach $key (sort keys %$perf_ref) {
if ($key =~ /last/) {
       print "$key\n";
    } else { 
   print scalar(localtime($key)) . "\n";
    }
print Dumper($perf_ref->{$key}) . "\n";
}

It looks like you are trying to measure br0 which is a virtual interface. It might be better to monitor the physical interface instead. I looked at a bridged interface I had and the results were strange. The receive counter was incrementing nicely while the transmit never changed, even when I pinged it.

user227563
  • 31
  • 2
2

I had the same issue with the revision 1.37 of the plugin using Ubuntu 14.04.

I tried to track it down by having perl check the script:

perl -Mstrict -cw bandwidth_

It complained about some strange use of split. I believe split needs a variable to assign the return value to. Probably this was changed in perl in one of the recent versions. The script is a bit dated.

Useless use of split in void context at bandwidth_ line 130.
Useless use of split in void context at bandwidth_ line 132.
Scalar value @_[0] better written as $_[0] at bandwidth_ line 212.
Useless use of split in void context at bandwidth_ line 211.

I do not care about the suggest function as i have already symlinked the plugin to the eth0 interface. Likely that part needs to be changed as well if you need it. The problem in my case was $uptime always being undefined, resulting in the return of 0.

So I changed the subroutine uptime to assign the return value to a variable and then use that.

sub uptime {
    my $puptime = "/proc/uptime";
    open( TIME, "<", $puptime ) || die "Unable to read $puptime: $!";
    while (<TIME>) {
        my @arr = split;
        $uptime = $arr[0];
    }
    close(TIME);
    chomp $uptime;
}

Now the plugin return values looking quite plausible.

user228505
  • 156
  • 3