diff options
Diffstat (limited to 'lib/Smokeping/probes/EchoPing.pm')
-rw-r--r-- | lib/Smokeping/probes/EchoPing.pm | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/lib/Smokeping/probes/EchoPing.pm b/lib/Smokeping/probes/EchoPing.pm index 95d1a6e..be3b681 100644 --- a/lib/Smokeping/probes/EchoPing.pm +++ b/lib/Smokeping/probes/EchoPing.pm @@ -74,33 +74,9 @@ sub new { $self->_init if $self->can('_init'); - # no need for this if running as a CGI - $self->test_usage unless $ENV{SERVER_SOFTWARE}; - return $self; } -# warn about unsupported features -sub test_usage { - my $self = shift; - my $bin = $self->{properties}{binary}; - my @unsupported; - - my $arghashref = $self->features; - my %arghash = %$arghashref; - for my $feature (keys %arghash) { - # when the option is invalid, then echoping would - # complain. if it is valid, then it will just display - # the usage message. - if (`$bin $arghash{$feature} 2>&1` !~ /^Usage/i) { - push @unsupported, $feature; - $self->do_log("Note: your echoping doesn't support the $feature feature (option $arghash{$feature}), disabling it"); - } - } - map { delete $arghashref->{$_} } @unsupported; - return; -} - sub ProbeDesc($) { return "TCP or UDP Echo pings using echoping(1)"; } @@ -205,14 +181,25 @@ sub pingone { open(P, "$cmd 2>&1 |") or carp("fork: $!"); - # what should we do with error messages? - my $echoret; + my @output; while (<P>) { - $echoret .= $_; + chomp; + push @output, $_; /^Elapsed time: (\d+\.\d+) seconds/ and push @times, $1; } close P; - $self->do_log("WARNING: $cmd was not happy: $echoret") if $?; + if ($?) { + my $status = $? >> 8; + my $signal = $? & 127; + my $why = "with status $status"; + $why .= " [signal $signal]" if $signal; + + # only log warnings on the first ping round + my $function = ($self->rounds_count == 1 ? "do_log" : "do_debug"); + + $self->$function(qq(WARNING: "$cmd" exited $why - output follows)); + $self->$function(qq( $_)) for @output; + } # carp("Got @times") if $self->debug; return sort { $a <=> $b } @times; } |