Munin plugin for ping response time
My ADSL router (a freebox) shows a recent tendency to desynchronize itself. That's annoying, even it that only lasts a few minutes from time to time. Maybe a cable needs to be replaced (advice?). So, I quickly hacked this plugin for Munin, an excellent system monitoring package:
#!/usr/bin/perl -wT
use strict;
our @HOSTS = qw(free.fr);
if (@ARGV && $ARGV[0] eq 'config') {
print <<CONFIG;
graph_title Ping response time
graph_vlabel time (ms)
graph_args --base 1000 -l 0
graph_scale no
graph_category network
CONFIG
for my $host (@HOSTS) {
my $name = $host;
$name =~ tr/./_/;
print "$name.label $host\n";
}
}
else {
@ENV{qw(PATH)} = qw(/bin);
for my $host (@HOSTS) {
my $name = $host;
$name =~ tr/./_/;
my @ping = qx(/bin/ping -nc1 $host 2>/dev/null);
my $times = $ping[-1];
my $val = '';
if ($times =~ m{^rtt min/avg/max/mdev = ([\d.]+)}) {
$val = $1;
}
print "$name.value $val\n";
}
}
Feel free to adapt/improve. This code is of course released under whatever license Munin is released under (I didn't bother to check.)
2 comments:
Thanks for posting this - exactly what I was looking for!
I made a few changes to your very nice script. The new ping script makes separate graphs per ip, and uses the symbolic link convention for ips. Thanks!
Post a Comment