summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2006-07-12 19:32:39 +0200
committerNiko Tyni <ntyni@iki.fi>2006-07-12 19:32:39 +0200
commit8e6a401ce24a3c479bc2f24fe0f594b44d8aba1f (patch)
treebc70ad771d7e797462bd8be7401b2f28d927cc19
parentd1830b25c0f16ffe684b75ce0c5e4bd2b3f552bb (diff)
downloadsmokeping-8e6a401ce24a3c479bc2f24fe0f594b44d8aba1f.tar.gz
smokeping-8e6a401ce24a3c479bc2f24fe0f594b44d8aba1f.tar.xz
* pass 'prevmatch' to alert matcher plugins.
-- niko, from Dylan Vanderhoof <DylanV *semaphore.com> (add to trunk as well)
-rw-r--r--CHANGES2
-rw-r--r--lib/Smokeping.pm6
-rw-r--r--lib/Smokeping/matchers/base.pm7
3 files changed, 14 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 84eb968..c9367ec 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+* pass 'prevmatch' to alert matcher plugins.
+ -- niko, from Dylan Vanderhoof <DylanV *semaphore.com>
* fix subject in tSmoke 'morning' emails. --niko,
from Jean-Philippe Luiggi <Jean-Philippe.Luiggi *revolutionlinux.com>
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index 49fdea8..9ff2578 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -1142,6 +1142,12 @@ sub update_rrds($$$$$) {
next;
};
my $prevmatch = $tree->{prevmatch}{$_} || 0;
+
+ # add the current state of an edge triggered alert to the
+ # data passed into a matcher, which allows for somewhat
+ # more intelligent alerting due to state awareness.
+ $x->{prevmatch} = $prevmatch;
+
my $match = &{$cfg->{Alerts}{$_}{sub}}($x) || 0; # Avgratio returns undef
my $edgetrigger = $cfg->{Alerts}{$_}{edgetrigger} eq 'yes';
my $what;
diff --git a/lib/Smokeping/matchers/base.pm b/lib/Smokeping/matchers/base.pm
index 130634f..0d69bcd 100644
--- a/lib/Smokeping/matchers/base.pm
+++ b/lib/Smokeping/matchers/base.pm
@@ -80,7 +80,7 @@ sub Desc ($) {
=head2 Test
Run the matcher and return true or false. The Test method is called
-with a hash of two arrays giving it access to both rtt and loss values.
+with a hash containing two arrays giving it access to both rtt and loss values.
my $data=shift;
my @rtt = @{$data->{rtt}};
@@ -93,6 +93,11 @@ The arrays are ordered from old to new.
There may be more than the expected number of elements in this array. Address them with
$x[-1] to $x[-max].
+There's also a key called 'prevmatch' in the hash. It contains the
+value returned by the previous call of the 'Test' method. This allows
+for somewhat more intelligent alerting due to state awareness.
+
+ my $prevmatch = $data->{prevmatch};
=cut