summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes/Curl.pm
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2005-03-10 12:00:44 +0100
committerNiko Tyni <ntyni@iki.fi>2005-03-10 12:00:44 +0100
commit021947ad8e963d89bdb00bd9de24dc962a3472bf (patch)
treed99bd1ba0798a89512e74af84c1b0a78b370fbf4 /lib/Smokeping/probes/Curl.pm
parent4d50cc7a6c80ea58ba492a875abcd250d44b1255 (diff)
downloadsmokeping-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
Diffstat (limited to 'lib/Smokeping/probes/Curl.pm')
-rw-r--r--lib/Smokeping/probes/Curl.pm43
1 files changed, 43 insertions, 0 deletions
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);
}