summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes/EchoPingHttp.pm
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2005-02-13 20:23:04 +0100
committerNiko Tyni <ntyni@iki.fi>2005-02-13 20:23:04 +0100
commit6d76521656e91daa160bc8019828f1b68d7aa5dc (patch)
treeaaa27615a0702942fa1606d9a5c89f0a3547467c /lib/Smokeping/probes/EchoPingHttp.pm
parent6dba1afbe4b475a7d34f5ef867b7b37291cd1484 (diff)
downloadsmokeping-6d76521656e91daa160bc8019828f1b68d7aa5dc.tar.gz
smokeping-6d76521656e91daa160bc8019828f1b68d7aa5dc.tar.xz
Moved probes, matchers and ciscoRttMonMIB modules to lib/Smokeping.
Diffstat (limited to 'lib/Smokeping/probes/EchoPingHttp.pm')
-rw-r--r--lib/Smokeping/probes/EchoPingHttp.pm143
1 files changed, 143 insertions, 0 deletions
diff --git a/lib/Smokeping/probes/EchoPingHttp.pm b/lib/Smokeping/probes/EchoPingHttp.pm
new file mode 100644
index 0000000..45f9bd9
--- /dev/null
+++ b/lib/Smokeping/probes/EchoPingHttp.pm
@@ -0,0 +1,143 @@
+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,
+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,
+EchoPing(3pm), EchoPingHttps(3pm)
+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 test_usage {
+ my $self = shift;
+ my $bin = $self->{properties}{binary};
+ croak("Your echoping binary doesn't support HTTP")
+ if `$bin -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i;
+ if (`$bin -a -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
+ carp("Note: your echoping binary doesn't support revalidating (-a), disabling it");
+ $self->{_disabled}{a} = undef;
+ }
+
+ if (`$bin -A -h/ 127.0.0.1 2>&1` =~ /(invalid option|not compiled|usage)/i) {
+ carp("Note: your echoping binary doesn't support ignoring cache (-A), disabling it");
+ $self->{_disabled}{A} = undef;
+ }
+
+ $self->SUPER::test_usage;
+ return;
+}
+
+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};
+ 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;