diff options
author | Tobias Oetiker <tobi@oetiker.ch> | 2012-02-02 23:21:31 +0100 |
---|---|---|
committer | Tobias Oetiker <tobi@oetiker.ch> | 2012-02-02 23:21:31 +0100 |
commit | f18024c3a610238aaf7d7101308367f72bc75e7d (patch) | |
tree | dc1fcf682f2c16b2acbd7e12a22e417954e363f5 | |
parent | f4f50a94f1beacfea12b3b1f1eb06251909cccc5 (diff) | |
download | smokeping-f18024c3a610238aaf7d7101308367f72bc75e7d.tar.gz smokeping-f18024c3a610238aaf7d7101308367f72bc75e7d.tar.xz |
handle servers actually implementing OPTIONS
-rw-r--r-- | lib/Smokeping/probes/SipSak.pm | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/Smokeping/probes/SipSak.pm b/lib/Smokeping/probes/SipSak.pm index b608427..a5b8a98 100644 --- a/lib/Smokeping/probes/SipSak.pm +++ b/lib/Smokeping/probes/SipSak.pm @@ -58,19 +58,30 @@ sub pingone { my @times; my $elapsed; my $pingcount = $self->pings($target); + my $keep = $vars->{keep_second}; $host = $vars->{user}.'@'.$host if $vars->{user}; - $host = $host . ':' . $vars->{port} if $vars->{port}; + $host = $host . ':' . $vars->{port} if $vars->{port}; my @extra_opts = (); @extra_opts = split /\s/, $vars->{params} if $vars->{params}; open (my $sak,'-|',$self->{properties}{binary},'-vv','-A',$pingcount,'-s','sip:'.$host,@extra_opts) or die("ERROR: $target->{binary}: $!\n"); - while(<$sak>){ - chomp; - if (/^(?:\s+and|\*\*\sreply\sreceived\safter)\s(\d+(?:\.\d+))\sms\s/){ + my $reply = join ("",<$sak>); + close $sak; + + my @reply = split /\*\*\sreply/, $reply; + # don't need the stuff before the first replyx + shift @reply; + + my $filter = '.*'; + if (scalar @reply > $pingcount){ + $filter = $keep eq 'yes' ? 'final' : 'provisional'; + } + for my $item (@reply){ + next unless $item =~ /$filter/; + if (/^(?:\s+and|\sreceived\safter)\s(\d+(?:\.\d+))\sms\s/){ push @times,$1/1000; } } - close $sak; return sort { $a <=> $b } @times; } @@ -105,6 +116,12 @@ sub targetvars { _doc => "additional sipsak options. The options will get split on space.", _example => '--numeric --password=mysecret' }, + full_test => { + _doc => "If OPTIONS is actually implemented by the server, SipSak will receive two responses. If this option is set, the timeing from the second, final response will be counter", + _example => 'yes', + _re => 'yes|no' + + } }); } |