~ubuntu-branches/debian/lenny/smokeping/lenny

« back to all changes in this revision

Viewing changes to lib/probes/EchoPingHttp.pm

  • Committer: Bazaar Package Importer
  • Author(s): Niko Tyni
  • Date: 2006-10-26 21:45:56 UTC
  • mfrom: (1.2.2 upstream) (2.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20061026214556-5jnpiesx4vdijmu6
* debian/patches/15_clean_makefile.dpatch:
  + remove unneeded and potentially unsecure include paths.
* debian/patches: selected patches from the upstream SVN repository
  + 40_password.dpatch: skip reading the password file when running as a CGI.
  + 50_ldap.dpatch: Make the 'scope' option in the LDAP probe actually work.
  + 60_fping.dpatch:
    * Support the '-S' (set source address, see #198486) fping option.
    * Don't try to execute fping when running as a CGI.
  + 70_syslog.dpatch: Don't die silently if syslogd is unavailable.
    (Closes: #395056)
* Remove all the autogenerated documentation at clean time, to properly
  undo the effects of the 'build' target.
* Install example configuration files for documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package probes::EchoPingHttp;
2
 
 
3
 
=head1 NAME
4
 
 
5
 
probes::EchoPingHttp - an echoping(1) probe for SmokePing
6
 
 
7
 
=head1 OVERVIEW
8
 
 
9
 
Measures HTTP roundtrip times (web servers and caches) for SmokePing.
10
 
 
11
 
=head1 SYNOPSYS
12
 
 
13
 
 *** Probes ***
14
 
 + EchoPingHttp
15
 
 
16
 
 binary = /usr/bin/echoping # mandatory
17
 
 
18
 
 
19
 
 *** Targets ***
20
 
 
21
 
 probe = EchoPingHttp
22
 
 
23
 
 + PROBE_CONF
24
 
 url = / 
25
 
 ignore_cache = yes
26
 
 revalidate_data = no
27
 
 port = 80 # default value anyway
28
 
 timeout = 50 # default is 10s
29
 
 
30
 
=head1 DESCRIPTION
31
 
 
32
 
Supported probe-specific variables: those specified in EchoPing(3pm) 
33
 
documentation.
34
 
 
35
 
Supported target-specific variables:
36
 
 
37
 
=over
38
 
 
39
 
=item those specified in EchoPing(3pm) documentation 
40
 
 
41
 
except I<fill>, I<size> and I<udp>.
42
 
 
43
 
=item url
44
 
 
45
 
The URL to be requested from the web server or cache. Can be either relative
46
 
(/...) for web servers or absolute (http://...) for caches.
47
 
 
48
 
=item port
49
 
 
50
 
The TCP port to use. The default is 80.
51
 
 
52
 
=item ignore_cache
53
 
 
54
 
The echoping(1) "-A" option: force the proxy to ignore the cache.
55
 
Enabled if the value is anything other than 'no' or '0'.
56
 
 
57
 
=item revalidate_data
58
 
 
59
 
The echoping(1) "-a" option: force the proxy to revalidate data with original 
60
 
server. Enabled if the value is anything other than 'no' or '0'.
61
 
 
62
 
=item timeout
63
 
 
64
 
The echoping(1) "-t" option: Number  of  seconds  to  wait a reply before giving up. For TCP,
65
 
this is the maximum number of seconds for the  whole  connection
66
 
(setup and data exchange).
67
 
 
68
 
=back
69
 
 
70
 
=head1 AUTHOR
71
 
 
72
 
Niko Tyni E<lt>ntyni@iki.fiE<gt>
73
 
 
74
 
=head1 SEE ALSO
75
 
 
76
 
EchoPing(3pm), EchoPingHttps(3pm)
77
 
 
78
 
=cut
79
 
 
80
 
use strict;
81
 
use base qw(probes::EchoPing);
82
 
use Carp;
83
 
 
84
 
sub _init {
85
 
        my $self = shift;
86
 
        # HTTP doesn't fit with filling or size
87
 
        my $arghashref = $self->features;
88
 
        delete $arghashref->{size};
89
 
        delete $arghashref->{fill};
90
 
}
91
 
 
92
 
# tag the port number after the hostname
93
 
sub make_host {
94
 
        my $self = shift;
95
 
        my $target = shift;
96
 
 
97
 
        my $host = $self->SUPER::make_host($target);
98
 
        my $port = $target->{vars}{port};
99
 
        $port = $self->{properties}{port} unless defined $port;
100
 
 
101
 
        $host .= ":$port" if defined $port;
102
 
        return $host;
103
 
}
104
 
 
105
 
sub proto_args {
106
 
        my $self = shift;
107
 
        my $target = shift;
108
 
        my $url = $target->{vars}{url};
109
 
        $url = $self->{properties}{url} unless defined $url;
110
 
        $url = "/" unless defined $url;
111
 
 
112
 
        my @args = ("-h", $url);
113
 
 
114
 
        # -t : timeout
115
 
        my $timeout = $target->{vars}{timeout};
116
 
        $timeout = $self->{properties}{timeout} 
117
 
                unless defined $timeout;
118
 
        push @args, "-t $timeout" if $timeout;
119
 
 
120
 
        # -A : ignore cache
121
 
        my $ignore = $target->{vars}{ignore_cache};
122
 
        $ignore = $self->{properties}{ignore_cache} 
123
 
                unless defined $ignore;
124
 
        $ignore = 1 
125
 
                if (defined $ignore and $ignore ne "no" 
126
 
                        and $ignore ne "0");
127
 
        push @args, "-A" if $ignore and not exists $self->{_disabled}{A};
128
 
 
129
 
        # -a : force cache to revalidate the data
130
 
        my $revalidate = $target->{vars}{revalidate_data};
131
 
        $revalidate = $self->{properties}{revalidate_data} 
132
 
                unless defined $revalidate;
133
 
        $revalidate= 1 if (defined $revalidate and $revalidate ne "no" 
134
 
                and $revalidate ne "0");
135
 
        push @args, "-a" if $revalidate and not exists $self->{_disabled}{a};
136
 
 
137
 
        return @args;
138
 
}
139
 
 
140
 
sub test_usage {
141
 
        my $self = shift;
142
 
        my $bin = $self->{properties}{binary};
143
 
        croak("Your echoping binary doesn't support HTTP")
144
 
                if `$bin -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i;
145
 
        if (`$bin -a -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
146
 
                carp("Note: your echoping binary doesn't support revalidating (-a), disabling it");
147
 
                $self->{_disabled}{a} = undef;
148
 
        }
149
 
 
150
 
        if (`$bin -A -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
151
 
                carp("Note: your echoping binary doesn't support ignoring cache (-A), disabling it");
152
 
                $self->{_disabled}{A} = undef;
153
 
        }
154
 
 
155
 
        $self->SUPER::test_usage;
156
 
        return;
157
 
}
158
 
 
159
 
sub ProbeDesc($) {
160
 
        return "HTTP pings using echoping(1)";
161
 
}
162
 
 
163
 
 
164
 
1;