summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2007-10-27 15:00:42 +0200
committerNiko Tyni <ntyni@iki.fi>2007-10-27 15:00:42 +0200
commitb2974cc84cbbefb8d117765acb7230530963aa5c (patch)
tree684981e37a36174d707e48bcf268317a7157f513 /lib/Smokeping
parent51243891b9e493882c59e582c5188f48e1127bed (diff)
downloadsmokeping-b2974cc84cbbefb8d117765acb7230530963aa5c.tar.gz
smokeping-b2974cc84cbbefb8d117765acb7230530963aa5c.tar.xz
* removed all the 'live' tests from the echoping probes --niko
* log a warning message on the first 'round' of pinging if curl or echoping exits with non-zero status --niko
Diffstat (limited to 'lib/Smokeping')
-rw-r--r--lib/Smokeping/probes/Curl.pm15
-rw-r--r--lib/Smokeping/probes/EchoPing.pm43
-rw-r--r--lib/Smokeping/probes/EchoPingChargen.pm9
-rw-r--r--lib/Smokeping/probes/EchoPingDiscard.pm9
-rw-r--r--lib/Smokeping/probes/EchoPingHttp.pm19
-rw-r--r--lib/Smokeping/probes/EchoPingHttps.pm11
-rw-r--r--lib/Smokeping/probes/EchoPingIcp.pm9
-rw-r--r--lib/Smokeping/probes/EchoPingPlugin.pm10
-rw-r--r--lib/Smokeping/probes/EchoPingSmtp.pm9
9 files changed, 29 insertions, 105 deletions
diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm
index 7328e35..166333f 100644
--- a/lib/Smokeping/probes/Curl.pm
+++ b/lib/Smokeping/probes/Curl.pm
@@ -303,7 +303,20 @@ sub pingone {
$self->do_debug("curl output: '$_', result: $val");
};
}
- close P and defined $val and push @times, $val;
+ close P;
+ if ($?) {
+ my $status = $? >> 8;
+ my $signal = $? & 127;
+ my $why = "with status $status";
+ $why .= " [signal $signal]" if $signal;
+
+ # only log warnings on the first ping of the first ping round
+ my $function = ($self->rounds_count == 1 and $i == 0) ?
+ "do_log" : "do_debug";
+
+ $self->$function(qq(WARNING: curl exited $why on $t->{addr}));
+ }
+ push @times, $val if defined $val;
}
# carp("Got @times") if $self->debug;
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;
}
diff --git a/lib/Smokeping/probes/EchoPingChargen.pm b/lib/Smokeping/probes/EchoPingChargen.pm
index a75153d..e6d0984 100644
--- a/lib/Smokeping/probes/EchoPingChargen.pm
+++ b/lib/Smokeping/probes/EchoPingChargen.pm
@@ -42,15 +42,6 @@ sub proto_args {
return ("-c");
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- croak("Your echoping binary doesn't support CHARGEN")
- if `$bin -c 2>&1` !~ /^Usage/i;
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "TCP Chargen pings using echoping(1)";
}
diff --git a/lib/Smokeping/probes/EchoPingDiscard.pm b/lib/Smokeping/probes/EchoPingDiscard.pm
index 490d373..bdd66a3 100644
--- a/lib/Smokeping/probes/EchoPingDiscard.pm
+++ b/lib/Smokeping/probes/EchoPingDiscard.pm
@@ -42,15 +42,6 @@ sub proto_args {
return ("-d", @args);
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- croak("Your echoping binary doesn't support DISCARD")
- if `$bin -d 2>&1` !~ /^Usage/i;
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "TCP or UDP Discard pings using echoping(1)";
}
diff --git a/lib/Smokeping/probes/EchoPingHttp.pm b/lib/Smokeping/probes/EchoPingHttp.pm
index 2f5ea32..1281a39 100644
--- a/lib/Smokeping/probes/EchoPingHttp.pm
+++ b/lib/Smokeping/probes/EchoPingHttp.pm
@@ -84,25 +84,6 @@ sub proto_args {
return @args;
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- croak("Your echoping binary doesn't support HTTP")
- if `$bin -h / 2>&1` !~ /^Usage/;
- if (`$bin -a -h / 2>&1` !~ /^Usage/) {
- carp("Note: your echoping binary doesn't support revalidating (-a), disabling it");
- $self->{_disabled}{a} = undef;
- }
-
- if (`$bin -A -h / 2>&1` !~ /^Usage/) {
- carp("Note: your echoping binary doesn't support ignoring cache (-A), disabling it");
- $self->{_disabled}{A} = undef;
- }
-
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "HTTP pings using echoping(1)";
}
diff --git a/lib/Smokeping/probes/EchoPingHttps.pm b/lib/Smokeping/probes/EchoPingHttps.pm
index 941df32..c9bcb0c 100644
--- a/lib/Smokeping/probes/EchoPingHttps.pm
+++ b/lib/Smokeping/probes/EchoPingHttps.pm
@@ -50,17 +50,6 @@ sub proto_args {
return ("-C", @args);
}
-sub test_usage {
- my $self = shift;
-
- my $bin = $self->{properties}{binary};
- my $response = `$bin -C -h / 0.0.0.1 2>&1`;
- croak("Your echoping binary doesn't support SSL")
- if ($response =~ /(not compiled|invalid option|usage)/i);
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "HTTPS pings using echoping(1)";
}
diff --git a/lib/Smokeping/probes/EchoPingIcp.pm b/lib/Smokeping/probes/EchoPingIcp.pm
index 17a1c50..1aaccc2 100644
--- a/lib/Smokeping/probes/EchoPingIcp.pm
+++ b/lib/Smokeping/probes/EchoPingIcp.pm
@@ -57,15 +57,6 @@ sub proto_args {
return @args;
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- croak("Your echoping binary doesn't support ICP")
- if `$bin -t1 -i/ 0.0.0.1 2>&1` =~ /not compiled|usage/i;
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "ICP pings using echoping(1)";
}
diff --git a/lib/Smokeping/probes/EchoPingPlugin.pm b/lib/Smokeping/probes/EchoPingPlugin.pm
index 0762f45..7c1a758 100644
--- a/lib/Smokeping/probes/EchoPingPlugin.pm
+++ b/lib/Smokeping/probes/EchoPingPlugin.pm
@@ -74,16 +74,6 @@ sub proto_args {
return ("-m", $plugin);
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- # is there anything smarter to do?
- croak("Your echoping binary doesn't support plugins. At least version 6 is required.")
- if `$bin -m improbable_plugin_name 0.0.0.1 2>&1` =~ /invalid option/i;
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "Pings using an echoping(1) plugin";
}
diff --git a/lib/Smokeping/probes/EchoPingSmtp.pm b/lib/Smokeping/probes/EchoPingSmtp.pm
index 74f7a64..1a6f3ae 100644
--- a/lib/Smokeping/probes/EchoPingSmtp.pm
+++ b/lib/Smokeping/probes/EchoPingSmtp.pm
@@ -50,15 +50,6 @@ sub proto_args {
return ("-S");
}
-sub test_usage {
- my $self = shift;
- my $bin = $self->{properties}{binary};
- croak("Your echoping binary doesn't support SMTP")
- if `$bin -S 2>&1` !~ /^Usage/;
- $self->SUPER::test_usage;
- return;
-}
-
sub ProbeDesc($) {
return "SMTP pings using echoping(1)";
}