[smokeping-users] Alert via program fails on raising edge

Peter Klausner peter.klausner at gmail.com
Fri Apr 21 17:53:55 MEST 2006


If you setup an external program for an edgetrigger alert,
the notification fails for the raising edge like so:
---8<----
Apr 20 17:35:10 probe1 smokeping[12626]: Alert someloss was raised for
Test.Localhost
Apr 20 17:35:10 probe1 smokeping[12626]: Use of uninitialized value in
system at /opt/smokeping/lib/Smokeping.pm line 1140.
Apr 20 17:35:10 probe1 smokeping[12626]: Can't exec "": No such file
or directory at /opt/smokeping/lib/Smokeping.pm line 1140.
--->8----

The external progrom _does_ run on falling edges,
but it never sees the promised sixth argument.
The offending code around line 1140 is:

----8<---
    my $what;
    if ($edgetrigger and $prevmatch != $match) {
        $what = ($prevmatch == 0 ? "was raised" : "was cleared");
    }
    if (not $edgetrigger and $match) {
        $what = "is active";
    }
    if ($what) {
    # send something
    ...
    if ( $addr =~ /^\|(.+)/) {
        if ($edgetrigger) {
1140:       system $1,$_,$line,$loss,$rtt,$tree->{host}, ($what =~/raise/);
        } else {
            system $1,$_,$line,$loss,$rtt,$tree->{host};
        }
---->8---

It seems this works only, if the arguments to system() are processed
left to right.
Otherwise the program, i.e. $1 pulled from the address, gets overwritten
from the 1st subpattern in ($what =~/raise/) - which is empty.

I simply replaced the supposed boolean value by $what
and changed the strings to 'raised' and 'cleared'.
This makes life easier in sloppily quoted shell scripts.
(And a wee bit harder to read in natural text emails,
but maybe that could be fixed in the template?)

See the attached trivial patch.


HTH,
Peter Klausner



PS: this is Smokeping 2.0.5 perl5 (revision 5.0 version 8 subversion 0)
  Platform:
    osname=linux, osvers=2.4.21, archname=i486-linux

-- Attached file removed by Ecartis and put at URL below --
-- Type: text/plain
-- Size: 1k (1150 bytes)
-- URL : http://lists.ee.ethz.ch/p/Smokeping.pm.diffu.txt


--
Unsubscribe mailto:smokeping-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:smokeping-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/smokeping-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the smokeping-users mailing list