summaryrefslogtreecommitdiffstats
path: root/lib/probes/RemoteFPing.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/probes/RemoteFPing.pm')
-rw-r--r--lib/probes/RemoteFPing.pm208
1 files changed, 83 insertions, 125 deletions
diff --git a/lib/probes/RemoteFPing.pm b/lib/probes/RemoteFPing.pm
index da87b6c..9f26fd3 100644
--- a/lib/probes/RemoteFPing.pm
+++ b/lib/probes/RemoteFPing.pm
@@ -1,57 +1,31 @@
package probes::RemoteFPing;
-=head1 NAME
+=head1 301 Moved Permanently
-probes::RemoteFPing - Remote FPing Probe for SmokePing
+This is a Smokeping probe module. Please use the command
-=head1 SYNOPSIS
+C<smokeping -man probes::RemoteFPing>
- *** Probes ***
- + RemoteFPing
- binary = /usr/bin/ssh
- packetsize = 1024
- rhost = HostA.foobar.com
- ruser = foo
- rbinary = /usr/local/sbin/fping
+to view the documentation or the command
- *** Targets ***
- + Targetname
- Probe = RemoteFPing
- Menu = menuname
- Title = Remote Fping from HostA to HostB
- Host = HostB.barfoo.com
+C<smokeping -makepod probes::RemoteFPing>
+to generate the POD document.
-=head1 DESCRIPTION
+=cut
+sub pod_hash {
+ return {
+ name => <<DOC,
+probes::RemoteFPing - Remote FPing Probe for SmokePing
+DOC
+ description => <<DOC,
Integrates the remote execution of FPing via ssh/rsh into smokeping.
The variable B<binary> must point to your copy of the ssh/rsh program.
-
-=head1 OPTIONS
-
-The B<binary> and B<rhost> are mandatory. The B<binary> option
-specifies the path of the remote shell program (usually ssh,
-rsh or remsh). Any other script or binary that can be called as
-
- binary [ -l ruser ] rhost rbinary
-
-may be used.
-
-The (optional) B<packetsize> option lets you configure the packetsize
-for the pings sent.
-
-The B<rhost> option specifies the remote device from where fping will
-be launched.
-
-The (optional) B<ruser> option allows you to specify the remote user,
-if different from the one running the smokeping daemon.
-
-The (optional) B<rbinary> option allows you to specify the location of
-the remote fping binary. If not specified the probe will assume that
-fping is in the remote host's path.
-
-=head1 NOTES
-
+The variable B<rbinary> must point to your copy of the fping program
+at the remote end.
+DOC
+ notes => <<'DOC',
It is important to make sure that you can access the remote machine
without a password prompt, otherwise this probe will not work properly.
To test just try something like this:
@@ -61,104 +35,88 @@ To test just try something like this:
The next thing you see must be fping's output.
The B<rhost>, B<ruser> and B<rbinary> variables used to be configured in
-the PROBE_CONF section of the first target or its parents They were moved
+the Targets section of the first target or its parents They were moved
to the Probes section, because the variables aren't really target-specific
-(all the targets are measured with the same parameters). The PROBE_CONF
+(all the targets are measured with the same parameters). The Targets
sections aren't recognized anymore.
+DOC
+ authors => <<'DOC',
+ Luis F Balbinot <hades@inf.ufrgs.br>
-=head1 AUTHOR
+ Niko Tyni <ntyni@iki.fi>
-Luis F Balbinot <hades@inf.ufrgs.br>
+ derived from probes::FPing by
-based on probes::FPing by
-
-Tobias Oetiker <tobi@oetiker.ch>
-
-=cut
+ Tobias Oetiker <tobi@oetiker.ch>
+DOC
+ bugs => <<DOC
+This functionality should be in a generic 'remote execution' module
+so that it could be used for the other probes too.
+DOC
+ }
+}
use strict;
-use base qw(probes::base);
-use IPC::Open3;
-use Symbol;
-use Carp;
-
-sub new($$$) {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self = $class->SUPER::new(@_);
-
- # no need for this if we run as a cgi
- unless ( $ENV{SERVER_SOFTWARE} ) {
- croak "ERROR: RemoteFPing packetsize must be between 12 and 64000"
- if $self->{properties}{packetsize} and
- ( $self->{properties}{packetsize} < 12 or $self->{properties}{packetsize} > 64000 );
-
- croak "ERROR: RemoteFPing 'binary' not defined in RemoteFPing probe definition"
- unless defined $self->{properties}{binary};
-
- croak "ERROR: RemoteFPing 'binary' does not point to an executable"
- unless -f $self->{properties}{binary} and -x $self->{properties}{binary};
-
- croak "ERROR: RemoteFPing 'rhost' not defined in RemoteFPing probe definition. This might be because the configuration syntax has changed. See the RemoteFPing manual for details."
- unless defined $self->{properties}{rhost};
-
- $self->{pingfactor} = 1000; # Gives us a good-guess default
- print "### assuming you are using a remote fping copy reporting in milliseconds\n";
- };
-
- return $self;
-}
+use base qw(probes::FPing);
sub ProbeDesc($) {
my $self = shift;
- my $bytes = $self->{properties}{packetsize} || 56;
- return "Remote ICMP Echo Pings ($bytes Bytes)";
+ my $superdesc = $self->SUPER::ProbeDesc;
+ return "Remote $superdesc";
}
-sub ping ($) {
+sub binary {
my $self = shift;
-
- # do NOT call superclass ... the ping method MUST be overwriten
- my %upd;
- my $inh = gensym;
- my $outh = gensym;
- my $errh = gensym;
- # pinging nothing is pointless
- return unless @{$self->addresses};
- my @bytes = ();
-
- push @bytes, "-b$self->{properties}{packetsize}" if $self->{properties}{packetsize};
-
- my @rargs;
+ my @ret = ( $self->SUPER::binary );
for my $what (qw(ruser rhost rbinary)) {
- my $prefix = ($what eq 'ruser' ? "-l" : "");
- if (defined $self->{properties}{$what}) {
- push @rargs, $prefix . $self->{properties}{$what};
- }
+ my $prefix = ($what eq 'ruser' ? "-l" : "");
+ if (defined $self->{properties}{$what}) {
+ push @ret, $prefix . $self->{properties}{$what};
+ }
}
+ return @ret;
+}
- my $query = "$self->{properties}{binary} @rargs @bytes -C " . $self->pings . " -q -B1 -i10 -r1 @{$self->addresses}";
-
- $self->do_debug("query=$query\n");
-
- my $pid = open3($inh,$outh,$errh,$query );
- my @times =() ;
- $self->{rtts}={};
- while (<$errh>) {
- chomp;
- next unless /^\S+\s+:\s+[\d\.]/; #filter out error messages from fping
- $self->do_debug("array element=$_ \n");
- @times = split /\s+/;
- my $ip = shift @times;
- next unless ':' eq shift @times; #drop the colon
- @times = map {sprintf "%.10e", $_ / $self->{pingfactor}} sort {$a <=> $b} grep {$_ ne "-"} @times;
- map { $self->{rtts}{$_} = [@times] } @{$self->{addrlookup}{$ip}} ;
- }
- waitpid $pid,0;
- close $inh;
- close $outh;
- close $errh;
- return @times;
+sub probevars {
+ my $class = shift;
+ my $h = $class->SUPER::probevars;
+ $h->{rbinary} = $h->{binary};
+ delete $h->{binary};
+ delete $h->{rbinary}{sub}; # we can't check the remote program's -x bit
+ @{$h->{_mandatory}} = map { $_ ne 'binary' ? $_ : 'rbinary' } @{$h->{_mandatory}};
+ return $class->_makevars($h, {
+ _mandatory => [ 'binary', 'rhost' ],
+ binary => {
+ _doc => <<DOC,
+This variable specifies the path of the remote shell program (usually ssh,
+rsh or remsh). Any other script or binary that can be called as
+
+binary [ -l ruser ] rhost rbinary
+
+may be used.
+DOC
+ _example => '/usr/bin/ssh',
+ _sub => sub {
+ my $val = shift;
+ -x $val or return "ERROR: binary '$val' is not executable";
+ return undef;
+ },
+ },
+ rhost => {
+ _doc => <<DOC,
+The B<rhost> option specifies the remote device from where fping will
+be launched.
+DOC
+ _example => 'my.pinger.host',
+ },
+ ruser => {
+ _doc => <<DOC,
+The (optional) B<ruser> option allows you to specify the remote user,
+if different from the one running the smokeping daemon.
+DOC
+ _example => 'foo',
+ },
+ });
}
1;