diff options
author | Niko Tyni <ntyni@iki.fi> | 2005-02-16 21:18:48 +0100 |
---|---|---|
committer | Niko Tyni <ntyni@iki.fi> | 2005-02-16 21:18:48 +0100 |
commit | 09df26f453b88aafaddf53c08c740d32e1342336 (patch) | |
tree | 31d0fca65fc939a40b78f768ed909a3c793b221c /lib/Smokeping/matchers/Median.pm | |
parent | 94f0e104fd177a53bc73ab83838522785e785623 (diff) | |
download | smokeping-09df26f453b88aafaddf53c08c740d32e1342336.tar.gz smokeping-09df26f453b88aafaddf53c08c740d32e1342336.tar.xz |
* announce smokeping version at startup
* add matcher list to smokeping_config
* make matcher names start with a capital letter
* make probe names start with a capital letter
* small doc updates
* one more pod2html makefile fix
Diffstat (limited to 'lib/Smokeping/matchers/Median.pm')
-rw-r--r-- | lib/Smokeping/matchers/Median.pm | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/lib/Smokeping/matchers/Median.pm b/lib/Smokeping/matchers/Median.pm new file mode 100644 index 0000000..3c8560a --- /dev/null +++ b/lib/Smokeping/matchers/Median.pm @@ -0,0 +1,80 @@ +package Smokeping::matchers::Median; + +=head1 NAME + +Smokeping::matchers::Median - Find persistant changes in latency + +=head1 OVERVIEW + +The idea behind this matcher is to find sustained changes in latency. + +The median matcher takes a number of past median latencies. It splits the latencies into +two groups (old and new) and again finds the median for each groups. If the +difference between the two medians is bigger than a certain value, it will +give a match. + +=head1 DESCRIPTION + +Call the matcher with the following sequence: + + type = matcher + pattern = Median(old=>x,new=>y,diff=>z) + +This will create a matcher which consumes x+y latency-datapoints, builds the +two medians and the matches if the difference between the median latency is +larger than z seconds. + +=head1 COPYRIGHT + +Copyright (c) 2004 by OETIKER+PARTNER AG. All rights reserved. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +=head1 AUTHOR + +Tobias Oetiker <tobi@oetiker.ch> + +=cut + +use strict; +use base qw(Smokeping::matchers::base); +use vars qw($VERSION); +$VERSION = 1.0; +use Carp; + +# how many values does the matcher need to do it's magic +sub Length($) +{ + my $self = shift; + return $self->{param}{old} + $self->{param}{new}; +} + +sub Desc ($) { + croak "Find changes in median latency"; +} + +sub Test($$) +{ my $self = shift; + my $data = shift; # @{$data->{rtt}} and @{$data->{loss}} + my $ac = $self->{param}{old}; + my $bc = $self->{param}{new}; + my $cc = $ac +$bc; + my $oldm = (sort {$a <=> $b} @{$data->{rtt}}[-$cc..-$bc-1])[int($a/2)]; + $ac++; + my $newm = (sort {$a <=> $b} @{$data->{rtt}}[-$bc..-1])[int($bc/2)]; + return abs($oldm-$newm) > $self->{param}{diff}; +} |