summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2007-04-14 20:11:37 +0200
committerNiko Tyni <ntyni@iki.fi>2007-04-14 20:11:37 +0200
commite8f080ca27f06e945747201fbd7a941e859bb4f0 (patch)
tree5d4a1879e66e0b8eab18847c82e9c69410b710a0 /lib/Smokeping
parentaeb0b49ee5c442ce66e675c83dadf44ee0ea8bbf (diff)
downloadsmokeping-e8f080ca27f06e945747201fbd7a941e859bb4f0.tar.gz
smokeping-e8f080ca27f06e945747201fbd7a941e859bb4f0.tar.xz
r1039@rispa: niko | 2007-04-13 21:57:43 +0300
initial version for a base plugin module
Diffstat (limited to 'lib/Smokeping')
-rw-r--r--lib/Smokeping/probes/EchoPingPlugin.pm74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/Smokeping/probes/EchoPingPlugin.pm b/lib/Smokeping/probes/EchoPingPlugin.pm
new file mode 100644
index 0000000..e9330fc
--- /dev/null
+++ b/lib/Smokeping/probes/EchoPingPlugin.pm
@@ -0,0 +1,74 @@
+package Smokeping::probes::EchoPingPlugin;
+
+=head1 301 Moved Permanently
+
+This is a Smokeping probe module. Please use the command
+
+C<smokeping -man Smokeping::probes::EchoPingPlugin>
+
+to view the documentation or the command
+
+C<smokeping -makepod Smokeping::probes::EchoPingPlugin>
+
+to generate the POD document.
+
+=cut
+
+sub pod_hash {
+ return {
+ name => <<DOC,
+Smokeping::probes::EchoPingPlugin - an echoping(1) probe for SmokePing
+DOC
+ overview => <<DOC,
+Measures roundtrip times for SmokePing with an echoping(1) plugin.
+DOC
+ authors => <<'DOC',
+Niko Tyni <ntyni@iki.fi>
+DOC
+ notes => <<'DOC',
+The I<fill>, I<size> and I<udp> EchoPing variables are not valid by default for EchoPingPlugin -derived probes.
+DOC
+ see_also => <<DOC,
+L<Smokeping::probes::EchoPing>
+DOC
+ }
+}
+
+use strict;
+use base qw(Smokeping::probes::EchoPing);
+use Carp;
+
+sub _init {
+ my $self = shift;
+ # plugins don't generally fit with filling, size or udp.
+ my $arghashref = $self->features;
+ delete $arghashref->{size};
+ delete $arghashref->{fill};
+ delete $arghashref->{udp};
+}
+
+
+sub proto_args {
+ my $self = shift;
+ my $target = shift;
+ my $plugin = $target->{vars}{plugin};
+ return ("-m", $plugin);
+}
+
+sub test_usage {
+ my $self = shift;
+ my $bin = $self->{properties}{binary};
+ # side effect: this sleeps for a random time between 0 and 1 seconds
+ # is there anything smarter to do?
+ croak("Your echoping binary doesn't support plugins")
+ if `$bin -m random 127.0.0.1 2>&1` =~ /(not compiled|invalid option|usage)/i;
+ $self->SUPER::test_usage;
+ return;
+}
+
+sub ProbeDesc($) {
+ return "Pings using an echoping(1) plugin";
+}
+
+
+1;