Skip to content

Commit

Permalink
Fixing a warning in the ping plugin
Browse files Browse the repository at this point in the history
Error message:
Use of uninitialized value $ping_time in concatenation (.) or string at /etc/munin/plugins/ping line 176.

Fix is to declare a variable prior to using it in postfix-if assignment
  • Loading branch information
dotdoom committed Sep 27, 2012
1 parent 4699dea commit d112f62
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/network/ping/ping
Expand Up @@ -171,8 +171,10 @@ for (my $host_i = 0; $host_i < @host_addrs; ++$host_i) {
my @ping = `$h_ping $ping_args $h_addr $ping_args2`;
chomp @ping;
my $ping = join(" ", @ping);
my $ping_time = ($1 / 1000) if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
my $packet_loss = $1 if ($ping =~ /(\d+)% packet loss/);
my $ping_time = "U";
my $packet_loss = "U";
$ping_time = ($1 / 1000) if ($ping =~ m@min/avg/max.*\s\d+(?:\.\d+)?/(\d+(?:\.\d+)?)/\d+(?:\.\d+)?@);
$packet_loss = $1 if ($ping =~ /(\d+)% packet loss/);
print "$h_norm_name.value ". ($packetloss_mode ? $packet_loss : $ping_time) . "\n";
if ($pid == 0) {
# this is a child process, don't forget to exit
Expand Down

0 comments on commit d112f62

Please sign in to comment.