1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
package Smokeping::probes::EchoPingHttp;
=head1 301 Moved Permanently
This is a Smokeping probe module. Please use the command
C<smokeping -man Smokeping::probes::EchoPingHttp>
to view the documentation or the command
C<smokeping -makepod Smokeping::probes::EchoPingHttp>
to generate the POD document.
=cut
use strict;
use base qw(Smokeping::probes::EchoPing);
use Carp;
sub pod_hash {
return {
name => <<DOC,
Smokeping::probes::EchoPingHttp - an echoping(1) probe for SmokePing
DOC
overview => <<DOC,
Measures HTTP roundtrip times (web servers and caches) for SmokePing.
DOC
notes => <<DOC,
You should consider setting a lower value for the C<pings> variable than the
default 20, as repetitive URL fetching may be quite heavy on the server.
The I<fill>, I<size> and I<udp> EchoPing variables are not valid for EchoPingHttp.
DOC
authors => <<'DOC',
Niko Tyni <ntyni@iki.fi>
DOC
see_also => <<DOC,
L<Smokeping::probes::EchoPing>, L<Smokeping::probes::EchoPingHttps>
DOC
}
}
sub _init {
my $self = shift;
# HTTP doesn't fit with filling or size
my $arghashref = $self->features;
delete $arghashref->{size};
delete $arghashref->{fill};
}
# tag the port number after the hostname
sub make_host {
my $self = shift;
my $target = shift;
my $host = $self->SUPER::make_host($target);
my $port = $target->{vars}{port};
$host .= ":$port" if defined $port;
return $host;
}
sub proto_args {
my $self = shift;
my $target = shift;
my $url = $target->{vars}{url};
my @args = ("-h", $url);
# -A : ignore cache
my $ignore = $target->{vars}{ignore_cache};
$ignore = 1
if (defined $ignore and $ignore ne "no"
and $ignore ne "0");
push @args, "-A" if $ignore and not exists $self->{_disabled}{A};
# -a : force cache to revalidate the data
my $revalidate = $target->{vars}{revalidate_data};
$revalidate= 1 if (defined $revalidate and $revalidate ne "no"
and $revalidate ne "0");
push @args, "-a" if $revalidate and not exists $self->{_disabled}{a};
return @args;
}
sub ProbeDesc($) {
return "HTTP pings using echoping(1)";
}
sub targetvars {
my $class = shift;
my $h = $class->SUPER::targetvars;
delete $h->{udp};
delete $h->{fill};
delete $h->{size};
$h->{timeout}{default} = 10;
$h->{timeout}{example} = 20;
return $class->_makevars($h, {
url => {
_doc => <<DOC,
The URL to be requested from the web server or cache. Can be either relative
(/...) for web servers or absolute (http://...) for caches.
DOC
_default => '/',
},
port => {
_doc => 'The TCP port to use.',
_example => 80,
_re => '\d+',
},
ignore_cache => {
_doc => <<DOC,
The echoping(1) "-A" option: force the proxy to ignore the cache.
Enabled if the value is anything other than 'no' or '0'.
DOC
_example => 'yes',
},
revalidate_data => {
_doc => <<DOC,
The echoping(1) "-a" option: force the proxy to revalidate data with original
server. Enabled if the value is anything other than 'no' or '0'.
DOC
_example => 'no',
},
});
}
1;
|