diff options
author | Tobias Oetiker <tobi@oetiker.ch> | 2012-10-24 21:06:10 +0200 |
---|---|---|
committer | Tobias Oetiker <tobi@oetiker.ch> | 2012-10-24 21:06:10 +0200 |
commit | 7dac5296d1e490adf5fcbfa8de0c398e1a5cf55a (patch) | |
tree | ee1a296c007704e51849bf7041928a3b41b2039b /lib | |
parent | ef24bb21f91c066129d1fbb4fb72493029a17c6a (diff) | |
parent | 70b3337a26a5cf8e3a4ef49f3491017715bf212b (diff) | |
download | smokeping-7dac5296d1e490adf5fcbfa8de0c398e1a5cf55a.tar.gz smokeping-7dac5296d1e490adf5fcbfa8de0c398e1a5cf55a.tar.xz |
Merge branch 'master' of github.com:oetiker/SmokePing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Smokeping/probes/Curl.pm | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm index 7b3d3a9..66c5560 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; |