summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Smokeping.pm10
-rw-r--r--lib/Smokeping/probes/Curl.pm41
2 files changed, 42 insertions, 9 deletions
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index f295a42..a483f60 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -740,7 +740,7 @@ sub get_detail ($$$$){
my $imghref;
my $max;
my @tasks;
- my %lasthight;
+ my %lastheight;
if ($mode eq 's'){
# in nave mode there is only one graph, so the height calculation
@@ -748,16 +748,16 @@ sub get_detail ($$$$){
$imgbase = $cfg->{General}{imgcache}."/".(join "/", @dirs)."/${file}";
$imghref = $cfg->{General}{imgurl}."/".(join "/", @dirs)."/${file}";
@tasks = @{$cfg->{Presentation}{detail}{_table}};
- if (open (HG,"<${imgbase}.maxhight")){
+ if (open (HG,"<${imgbase}.maxheight")){
while (<HG>){
chomp;
my @l = split / /;
- $lasthight{$l[0]} = $l[1];
+ $lastheight{$l[0]} = $l[1];
}
close HG;
}
$max = findmax $cfg, $rrd;
- if (open (HG,">${imgbase}.maxhight")){
+ if (open (HG,">${imgbase}.maxheight")){
foreach my $s (keys %{$max}){
print HG "$s $max->{$s}\n";
}
@@ -906,7 +906,7 @@ sub get_detail ($$$$){
$cfg->{Presentation}{detail}{logarithmic} eq 'yes';
my @lazy =();
- @lazy = ('--lazy') if $mode eq 's' and $lasthight{$start} and $lasthight{$start} == $max->{$start};
+ @lazy = ('--lazy') if $mode eq 's' and $lastheight{$start} and $lastheight{$start} == $max->{$start};
$desc = "Navigator Graph" if $mode eq 'n';
my $timer_start = time();
my @task =
diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm
index 6e4625a..2e2ef01 100644
--- a/lib/Smokeping/probes/Curl.pm
+++ b/lib/Smokeping/probes/Curl.pm
@@ -128,6 +128,26 @@ DOC
return undef;
},
},
+ follow_redirects => {
+ _doc => <<DOC,
+If this variable is set to 'yes', curl will follow any HTTP redirection steps (the '-L' option).
+If set to 'no', HTTP Location: headers will not be followed. See also 'include_redirects'.
+DOC
+ _default => "no",
+ _re => "(yes|no)",
+ _example => "yes",
+ },
+
+ include_redirects => {
+ _doc => <<DOC,
+If this variable is set to 'yes', the measurement result will include the time
+spent on following any HTTP redirection steps. If set to 'no', only the last
+step is measured. See also 'follow_redirects'.
+DOC
+ _default => "no",
+ _re => "(yes|no)",
+ _example => "yes",
+ },
extraargs => {
_doc => <<DOC,
Any extra arguments you might want to hand to curl(1). The arguments
@@ -189,7 +209,9 @@ sub test_usage {
}
}
map { delete $arghashref->{$_} } @unsupported;
-
+ if (`$bin -o /dev/null -w '<%{time_redirect}>\n' 127.0.0.1 2>&1` =~ /^<>/m) {
+ $self->do_log("Note: your curl doesn't support the 'time_redirect' output variable; 'include_redirects' will not function.");
+ }
return;
}
@@ -217,11 +239,13 @@ sub proto_args {
my $target = shift;
# XXX - It would be neat if curl had a "time_transfer". For now,
# we take the total time minus the DNS lookup time.
- my @args = ("-o", "/dev/null", "-w", "Time: %{time_total} DNS time: %{time_namelookup}\\n");
+ my @args = ("-w", "Time: %{time_total} DNS time: %{time_namelookup} Redirect time: %{time_redirect}\\n");
my $ssl2 = $target->{vars}{ssl2};
push (@args, "-2") if $ssl2;
my $insecure_ssl = $target->{vars}{insecure_ssl};
push (@args, '-k') if $insecure_ssl;
+ my $follow = $target->{vars}{follow_redirects};
+ push (@args, '-L') if $follow eq "yes";
return(@args);
}
@@ -245,10 +269,12 @@ sub make_commandline {
my $url = $target->{vars}{urlformat};
my $host = $target->{addr};
$url =~ s/%host%/$host/g;
+ my @urls = split(/\s+/, $url);
+ push @args, ("-o", "/dev/null") for (@urls);
push @args, $self->proto_args($target);
push @args, $self->extra_args($target);
- return ($self->{properties}{binary}, @args, $url);
+ return ($self->{properties}{binary}, @args, @urls);
}
sub pingone {
@@ -268,7 +294,14 @@ sub pingone {
my $val;
while (<P>) {
- /^Time: (\d+\.\d+) DNS time: (\d+\.\d+)/ and $val = $1 - $2;
+ chomp;
+ /^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;
+ }
+ $self->do_debug("curl output: '$_', result: $val");
+ };
}
close P and defined $val and push @times, $val;
}