diff --git a/plugins/other/multipng_async b/plugins/other/multipng_async index 5213d48e..eb836149 100755 --- a/plugins/other/multipng_async +++ b/plugins/other/multipng_async @@ -22,7 +22,7 @@ The following environment variables are used: host - Whitespace-seperated list of hosts to ping times - How many times to ping the hosts, 3 by default - timeout - The ping timeout (ping -W), 1 by default + timeout - The ping timeout (ping -W), 1 by default (ignored on Solaris) title - The graph_title to use for the munin RRD graph category - What category the graph should be in, network by default @@ -51,7 +51,8 @@ away from it due to having odd timing issues with it, and it had to run as root. This plugin requires the L and L modules -from CPAN. +from CPAN. It has been tested with the Linux, FreeBSD and Solaris +L implementations. =head1 AUTHOR @@ -138,22 +139,39 @@ sub START { return; } - for ($self->hosts) { + for my $host ($self->hosts) { POE::Quickie->new->run( - Program => [ 'ping', '-c', $self->times, '-W', $self->timeout, => $_ ], + Program => [ $self->ping_arguments($host) ], StdoutEvent => 'stdout', ExitEvent => 'exit', - Context => $_, + Context => $host, ); } } +sub ping_arguments { + my ($self, $host) = @_; + + given ($^O) { + when ('solaris') { + return ('ping', '-s', $host, '64', $self->times); + } + default { + # Linux and FreeBSD + return ('ping', '-c', $self->times, '-W', $self->timeout, => $host); + } + } +} + event stdout => sub { my ($self, $output, undef, $context) = @_; given ($output) { my $noslash = qr{[^/]+}; - when (m[^rtt min/avg/max/mdev = (?$noslash)/(?$noslash)/(?$noslash)/]) { + # Linux output: rtt min/avg/max/mdev = 7.218/7.255/7.293/0.030 ms + # BSD output : round-trip min/avg/max/stddev = 34.935/35.665/36.684/0.743 ms + # Solaris : round-trip (ms) min/avg/max/stddev = 5.82/5.95/6.01/0.11 + when (m[= (?$noslash)/(?$noslash)/(?$noslash)/]) { $self->response->{ $context } = $+{avg}; } }