summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--doc/smokeping_upgrade.pod2
-rw-r--r--lib/Smokeping/probes/Curl.pm43
3 files changed, 47 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 8a2e9c2..8fbfad9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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);
}