1
package probes::RemoteFPing;
5
probes::RemoteFPing - Remote FPing Probe for SmokePing
13
rhost = HostA.foobar.com
15
rbinary = /usr/local/sbin/fping
21
Title = Remote Fping from HostA to HostB
22
Host = HostB.barfoo.com
27
Integrates the remote execution of FPing via ssh/rsh into smokeping.
28
The variable B<binary> must point to your copy of the ssh/rsh program.
32
The B<binary> and B<rhost> are mandatory. The B<binary> option
33
specifies the path of the remote shell program (usually ssh,
34
rsh or remsh). Any other script or binary that can be called as
36
binary [ -l ruser ] rhost rbinary
40
The (optional) B<packetsize> option lets you configure the packetsize
43
The B<rhost> option specifies the remote device from where fping will
46
The (optional) B<ruser> option allows you to specify the remote user,
47
if different from the one running the smokeping daemon.
49
The (optional) B<rbinary> option allows you to specify the location of
50
the remote fping binary. If not specified the probe will assume that
51
fping is in the remote host's path.
55
It is important to make sure that you can access the remote machine
56
without a password prompt, otherwise this probe will not work properly.
57
To test just try something like this:
59
$ ssh foo@HostA.foobar.com fping HostB.barfoo.com
61
The next thing you see must be fping's output.
63
The B<rhost>, B<ruser> and B<rbinary> variables used to be configured in
64
the PROBE_CONF section of the first target or its parents They were moved
65
to the Probes section, because the variables aren't really target-specific
66
(all the targets are measured with the same parameters). The PROBE_CONF
67
sections aren't recognized anymore.
71
Luis F Balbinot <hades@inf.ufrgs.br>
73
based on probes::FPing by
75
Tobias Oetiker <tobi@oetiker.ch>
80
use base qw(probes::base);
87
my $class = ref($proto) || $proto;
88
my $self = $class->SUPER::new(@_);
90
# no need for this if we run as a cgi
91
unless ( $ENV{SERVER_SOFTWARE} ) {
92
croak "ERROR: RemoteFPing packetsize must be between 12 and 64000"
93
if $self->{properties}{packetsize} and
94
( $self->{properties}{packetsize} < 12 or $self->{properties}{packetsize} > 64000 );
96
croak "ERROR: RemoteFPing 'binary' not defined in RemoteFPing probe definition"
97
unless defined $self->{properties}{binary};
99
croak "ERROR: RemoteFPing 'binary' does not point to an executable"
100
unless -f $self->{properties}{binary} and -x $self->{properties}{binary};
102
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."
103
unless defined $self->{properties}{rhost};
105
$self->{pingfactor} = 1000; # Gives us a good-guess default
106
print "### assuming you are using a remote fping copy reporting in milliseconds\n";
114
my $bytes = $self->{properties}{packetsize} || 56;
115
return "Remote ICMP Echo Pings ($bytes Bytes)";
121
# do NOT call superclass ... the ping method MUST be overwriten
126
# pinging nothing is pointless
127
return unless @{$self->addresses};
130
push @bytes, "-b$self->{properties}{packetsize}" if $self->{properties}{packetsize};
133
for my $what (qw(ruser rhost rbinary)) {
134
my $prefix = ($what eq 'ruser' ? "-l" : "");
135
if (defined $self->{properties}{$what}) {
136
push @rargs, $prefix . $self->{properties}{$what};
140
my $query = "$self->{properties}{binary} @rargs @bytes -C " . $self->pings . " -q -B1 -i10 -r1 @{$self->addresses}";
142
$self->do_debug("query=$query\n");
144
my $pid = open3($inh,$outh,$errh,$query );
149
next unless /^\S+\s+:\s+[\d\.]/; #filter out error messages from fping
150
$self->do_debug("array element=$_ \n");
151
@times = split /\s+/;
152
my $ip = shift @times;
153
next unless ':' eq shift @times; #drop the colon
154
@times = map {sprintf "%.10e", $_ / $self->{pingfactor}} sort {$a <=> $b} grep {$_ ne "-"} @times;
155
map { $self->{rtts}{$_} = [@times] } @{$self->{addrlookup}{$ip}} ;