~ubuntu-branches/ubuntu/edgy/smokeping/edgy-proposed

« back to all changes in this revision

Viewing changes to lib/probes/EchoPingHttp.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2002-04-02 15:02:08 UTC
  • Revision ID: james.westby@ubuntu.com-20020402150208-8eycqntc07q6gig5
Tags: upstream-1.6
ImportĀ upstreamĀ versionĀ 1.6

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
 force-revalidate = no
 
27
 port = 80 # default value anyway
 
28
 
 
29
=head1 DESCRIPTION
 
30
 
 
31
Supported probe-specific variables: those specified in EchoPing(3pm) 
 
32
documentation.
 
33
 
 
34
Supported target-specific variables:
 
35
 
 
36
=over
 
37
 
 
38
=item those specified in EchoPing(3pm) documentation 
 
39
 
 
40
except I<fill>, I<size> and I<udp>.
 
41
 
 
42
=item url
 
43
 
 
44
The URL to be requested from the web server or cache. Can be either relative
 
45
(/...) for web servers or absolute (http://...) for caches.
 
46
 
 
47
=item port
 
48
 
 
49
The TCP port to use. The default is 80.
 
50
 
 
51
=item ignore_cache
 
52
 
 
53
The echoping(1) "-A" option: force the proxy to ignore the cache.
 
54
Enabled if the value is anything other than 'no' or '0'.
 
55
 
 
56
=item revalidate_data
 
57
 
 
58
The echoping(1) "-a" option: force the proxy to revalidate data with original 
 
59
server. Enabled if the value is anything other than 'no' or '0'.
 
60
 
 
61
=back
 
62
 
 
63
=head1 AUTHOR
 
64
 
 
65
Niko Tyni E<lt>ntyni@iki.fiE<gt>
 
66
 
 
67
=head1 SEE ALSO
 
68
 
 
69
EchoPing(3pm), EchoPingHttps(3pm)
 
70
 
 
71
=cut
 
72
 
 
73
use strict;
 
74
use base qw(probes::EchoPing);
 
75
use Carp;
 
76
 
 
77
sub _init {
 
78
        my $self = shift;
 
79
        # HTTP doesn't fit with filling or size
 
80
        my $arghashref = $self->features;
 
81
        delete $arghashref->{size};
 
82
        delete $arghashref->{fill};
 
83
}
 
84
 
 
85
# tag the port number after the hostname
 
86
sub make_host {
 
87
        my $self = shift;
 
88
        my $target = shift;
 
89
 
 
90
        my $host = $self->SUPER::make_host($target);
 
91
        my $port = $target->{vars}{port};
 
92
        $port = $self->{properties}{port} unless defined $port;
 
93
 
 
94
        $host .= ":$port" if defined $port;
 
95
        return $host;
 
96
}
 
97
 
 
98
sub proto_args {
 
99
        my $self = shift;
 
100
        my $target = shift;
 
101
        my $url = $target->{vars}{url};
 
102
        $url = $self->{properties}{url} unless defined $url;
 
103
        $url = "/" unless defined $url;
 
104
 
 
105
        my @args = ("-h", $url);
 
106
 
 
107
 
 
108
        # -A : ignore cache
 
109
        my $ignore = $target->{vars}{ignore_cache};
 
110
        $ignore = $self->{properties}{ignore_cache} 
 
111
                unless defined $ignore;
 
112
        $ignore = 1 
 
113
                if (defined $ignore and $ignore ne "no" 
 
114
                        and $ignore != 0);
 
115
        push @args, "-A" if $ignore and not exists $self->{_disabled}{A};
 
116
 
 
117
        # -a : force cache to revalidate the data
 
118
        my $revalidate = $target->{vars}{revalidate_data};
 
119
        $revalidate = $self->{properties}{revalidate_data} 
 
120
                unless defined $revalidate;
 
121
        $revalidate= 1 if (defined $revalidate and $revalidate ne "no" 
 
122
                and $revalidate != 0);
 
123
        push @args, "-a" if $revalidate and not exists $self->{_disabled}{a};
 
124
 
 
125
        return @args;
 
126
}
 
127
 
 
128
sub test_usage {
 
129
        my $self = shift;
 
130
        my $bin = $self->{properties}{binary};
 
131
        croak("Your echoping binary doesn't support HTTP")
 
132
                if `$bin -h/ foo 2>&1` =~ /(invalid option|not compiled|usage)/i;
 
133
        if (`$bin -a -h/ foo 2>&1` =~ /(invalid option|not compiled|usage)/i) {
 
134
                carp("Note: your echoping binary doesn't support revalidating (-a), disabling it");
 
135
                $self->{_disabled}{a} = undef;
 
136
        }
 
137
 
 
138
        if (`$bin -A -h/ foo 2>&1` =~ /(invalid option|not compiled|usage)/i) {
 
139
                carp("Note: your echoping binary doesn't support ignoring cache (-A), disabling it");
 
140
                $self->{_disabled}{A} = undef;
 
141
        }
 
142
 
 
143
        $self->SUPER::test_usage;
 
144
        return;
 
145
}
 
146
 
 
147
sub ProbeDesc($) {
 
148
        return "HTTP pings using echoping(1)";
 
149
}
 
150
 
 
151
 
 
152
1;