summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Weatherford <jweather@xidus.net>2012-09-12 17:34:35 +0200
committerJeremy Weatherford <jweather@xidus.net>2012-09-12 17:34:35 +0200
commit7d68f748c5fdb8e1fe8d5daeb1deda2b9dafa435 (patch)
tree779206904b8cf0e68b09f7ee02c315eb9c015933
parent49572f3da6f0e62adbcb3d326c698fad941164f4 (diff)
downloadsmokeping-7d68f748c5fdb8e1fe8d5daeb1deda2b9dafa435.tar.gz
smokeping-7d68f748c5fdb8e1fe8d5daeb1deda2b9dafa435.tar.xz
add expect parameter to Curl.pm
-rw-r--r--lib/Smokeping/probes/Curl.pm19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm
index 7b3d3a9..b9c10e7 100644
--- a/lib/Smokeping/probes/Curl.pm
+++ b/lib/Smokeping/probes/Curl.pm
@@ -164,6 +164,14 @@ and then specify C<extraargs = --header;Host: www.example.com>.
DOC
_example => "-6 --head --user user:password",
},
+ expect => {
+ _doc => <<DOC,
+Require the given text to appear somewhere in the response, otherwise
+probe is treated as a failure
+DOC
+ _default => "",
+ _example => "Status: green",
+ },
});
}
@@ -271,7 +279,7 @@ sub make_commandline {
my $host = $target->{addr};
$url =~ s/%host%/$host/g;
my @urls = split(/\s+/, $url);
- push @args, ("-o", "/dev/null") for (@urls);
+# push @args, ("-o", "/dev/null") for (@urls);
push @args, $self->proto_args($target);
push @args, $self->extra_args($target);
@@ -293,10 +301,15 @@ sub pingone {
open(P, "-|") or exec @cmd;
my $val;
+ my $expectOK = 1;
+ $expectOK = 0 if ($t->{vars}{expect} ne "");
while (<P>) {
chomp;
- /^Time: (\d+\.\d+) DNS time: (\d+\.\d+) Redirect time: (\d+\.\d+)?/ and do {
+ if (!$expectOK and index($_, $t->{vars}{expect}) != -1) {
+ $expectOK = 1;
+ }
+ /Time: (\d+\.\d+) DNS time: (\d+\.\d+) Redirect time: (\d+\.\d+)?/ and do {
$val += $1 - $2;
if ($t->{vars}{include_redirects} eq "yes" and defined $3) {
$val += $3;
@@ -317,7 +330,7 @@ sub pingone {
$self->$function(qq(WARNING: curl exited $why on $t->{addr}));
}
- push @times, $val if defined $val;
+ push @times, $val if (defined $val and $expectOK);
}
# carp("Got @times") if $self->debug;