diff options
author | Niko Tyni <ntyni@iki.fi> | 2005-03-10 12:00:44 +0100 |
---|---|---|
committer | Niko Tyni <ntyni@iki.fi> | 2005-03-10 12:00:44 +0100 |
commit | 021947ad8e963d89bdb00bd9de24dc962a3472bf (patch) | |
tree | d99bd1ba0798a89512e74af84c1b0a78b370fbf4 | |
parent | 4d50cc7a6c80ea58ba492a875abcd250d44b1255 (diff) | |
download | smokeping-021947ad8e963d89bdb00bd9de24dc962a3472bf.tar.gz smokeping-021947ad8e963d89bdb00bd9de24dc962a3472bf.tar.xz |
* 2.0/lib/Smokeping/probes/Curl.pm,
2.0/doc/smokeping_upgrade.pod,
2.0/CHANGES:
+ new variables: extraargs and extrare
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | doc/smokeping_upgrade.pod | 2 | ||||
-rw-r--r-- | lib/Smokeping/probes/Curl.pm | 43 |
3 files changed, 47 insertions, 0 deletions
@@ -1,3 +1,5 @@ +* Curl now has a new "extraargs" option for any extra arguments, like "--header" + -- niko, requested by Warrick FitzGerald <lists.smokeping.wfitzgerald *crtman.com> * change ISG::ParseConfig references to its new name, Config::Grammar -- niko * don't create any RRD files if running as a CGI -- niko * Curl timeouts work better now -- niko, reported by Chris Wilson <chris *aidworld.org> diff --git a/doc/smokeping_upgrade.pod b/doc/smokeping_upgrade.pod index bd3b93a..41e109b 100644 --- a/doc/smokeping_upgrade.pod +++ b/doc/smokeping_upgrade.pod @@ -148,6 +148,8 @@ quotes are not needed anymore around the User-Agent string (the C<agent> parameter). Smokeping will complain if it notices quotes around the string. +Any extra arguments for C<curl> can now be specified in the C<extraargs> variable. + =item L<EchoPingHttp|Smokeping::probes::EchoPingHttp> The default timeout of this probe has been raised to 10 seconds. diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm index 56dd338..e00c749 100644 --- a/lib/Smokeping/probes/Curl.pm +++ b/lib/Smokeping/probes/Curl.pm @@ -102,6 +102,38 @@ host to be probed. DOC _example => "http://%host%/", }, + extrare=> { + _doc => <<DOC, +The regexp used to split the extraargs string into an argument list, +in the "/regexp/" notation. This contains just the space character +(" ") by default, but if you need to specify any arguments containing spaces, +you can set this variable to a different value. +DOC + _default => "/ /", + _example => "/ /", + _sub => sub { + my $val = shift; + return "extrare should be specified in the /regexp/ notation" + unless $val =~ m,^/.*/$,; + return undef; + }, + }, + extraargs => { + _doc => <<DOC, +Any extra arguments you might want to hand to curl(1). The arguments +should be separated by the regexp specified in "extrare", which +contains just the space character (" ") by default. + +Note that curl will be called with the resulting list of arguments +without any shell expansion. If you need to specify any arguments +containing spaces, you should set "extrare" to something else. + +As a complicated example, to explicitly set the "Host:" header in Curl +requests, you need to set "extrare" to something else, eg. "/;/", +and then specify C<extraargs = --header;Host: www.example.com>. +DOC + _example => "-6 --head --user user:password", + }, }); } @@ -181,6 +213,16 @@ sub proto_args { return(@args); } +sub extra_args { + my $self = shift; + my $target = shift; + my $args = $target->{vars}{extraargs}; + return () unless defined $args; + my $re = $target->{vars}{extrare}; + ($re =~ m,^/(.*)/$,) and $re = qr{$1}; + return split($re, $args); +} + sub make_commandline { my $self = shift; my $target = shift; @@ -191,6 +233,7 @@ sub make_commandline { my $host = $target->{addr}; $url =~ s/%host%/$host/g; push @args, $self->proto_args($target); + push @args, $self->extra_args($target); return ($self->{properties}{binary}, @args, $url); } |