From 2308a4663349102ad0f00989da53b0b0f2e89586 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Tue, 24 Oct 2006 05:43:58 +0000 Subject: added source address patch with -S check ... updated version numbers in files ... --- lib/Smokeping/probes/FPing.pm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/Smokeping/probes/FPing.pm') 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; }, @@ -188,6 +193,15 @@ The fping "-i" parameter, but in (probably fractional) seconds rather than 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 => <