summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes/FPing.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Smokeping/probes/FPing.pm')
-rw-r--r--lib/Smokeping/probes/FPing.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/Smokeping/probes/FPing.pm b/lib/Smokeping/probes/FPing.pm
index 553aaae..f717ae2 100644
--- a/lib/Smokeping/probes/FPing.pm
+++ b/lib/Smokeping/probes/FPing.pm
@@ -59,6 +59,8 @@ sub new($$$)
my $binary = join(" ", $self->binary);
my $testhost = $self->testhost;
my $return = `$binary -C 1 $testhost 2>&1`;
+ $self->{enable}{S} = (`$binary -h 2>&1` =~ /\s-S\s/);
+ carp "NOTE: your sping binary doesn't support source address setting (-S), disabling it";
croak "ERROR: fping ('$binary -C 1 $testhost') could not be run: $return"
if $return =~ m/not found/;
croak "ERROR: FPing must be installed setuid root or it will not work\n"
@@ -103,10 +105,12 @@ sub ping ($){
# pinging nothing is pointless
return unless @{$self->addresses};
my @params = () ;
- push @params , "-b$self->{properties}{packetsize}" if $self->{properties}{packetsize};
+ push @params, "-b$self->{properties}{packetsize}" if $self->{properties}{packetsize};
push @params, "-t" . int(1000 * $self->{properties}{timeout}) if $self->{properties}{timeout};
push @params, "-i" . int(1000 * $self->{properties}{mininterval});
push @params, "-p" . int(1000 * $self->{properties}{hostinterval}) if $self->{properties}{hostinterval};
+ push @params, "-S$self->{properties}{sourceaddress}" $self->{properties}{sourceaddress} and $self->{enable}{S};
+
my @cmd = (
$self->binary,
'-C', $self->pings, '-q','-B1','-r1',
@@ -122,7 +126,7 @@ sub ping ($){
my @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 /^\d/, @times;
map { $self->{rtts}{$_} = [@times] } @{$self->{addrlookup}{$ip}} ;
}
@@ -139,7 +143,8 @@ sub probevars {
binary => {
_sub => sub {
my ($val) = @_;
- return "ERROR: FPing 'binary' does not point to an executable"
+ return undef if $ENV{SERVER_SOFTWARE}; # don't check for fping presence in cgi mode
+ return "ERROR: FPing 'binary' does not point to an executable"
unless -f $val and -x _;
return undef;
},
@@ -190,6 +195,15 @@ milliseconds, for consistency with other Smokeping probes. From fping(1):
The minimum amount of time between sending a ping packet to any target.
DOC
},
+ sourceaddress => {
+ _re => '(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}',
+ _example => '192.168.0.1',
+ _doc => <<DOC,
+The fping "-S" parameter . From fping(1):
+
+Set source address.
+DOC
+ },
});
}