monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[monit-dev] [PATCH] Pass correct MONIT_DESCRIPTION env variable for exte


From: Marco Roeland
Subject: [monit-dev] [PATCH] Pass correct MONIT_DESCRIPTION env variable for external program
Date: Fri, 23 Jul 2010 13:46:39 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hello,

I use a "check host" statement in which multiple ports are monitored. The
alerts are passed on to an external script which uses the environment
variables that monit sets. In some cases where multiple "failed" and
"succeeded" events are raised, the value for MONIT_DESCRIPTION is
wrong, namely that of a different event. The existing code always seems
to use Event_get_message() for the first entry in the eventlist, even if
the event itself is not the first on that list.

The attached patch fixes this for me, although it is quiet invasive as
it modifies the "spawn" prototype. Perhaps someone sees a more elegant
solution?

The patch is against SVN revision 205 on "trunk".

Here is an example snippet for monitrc to illustrate the situation:

check host appserver with address 192.168.1.1
        start program = "/home/marco/bin/appserver --workdir 
/home/marco/testsuite/appserver --daemon"
        stop program = "/home/marco/bin/appserver --workdir 
/home/marco/testsuite/appserver --quit"
    if failed port 9080 protocol http with timeout 5 seconds
        then exec "/home/marco/src/test-monit/bin/my_alert 'Failed for port 
9080'"
        else if succeeded then exec "/home/marco/src/test-monit/bin/my_alert 
'Succeeded for port 9080'"
    if failed port 9081 protocol http with timeout 5 seconds
        then exec "/home/marco/src/test-monit/bin/my_alert 'Failed for port 
9081'"
        else if succeeded then exec "/home/marco/src/test-monit/bin/my_alert 
'Succeeded for port 9081'"
    if failed port 9082 protocol http with timeout 5 seconds
        then exec "/home/marco/src/test-monit/bin/my_alert 'Failed for port 
9082'"
        else if succeeded then exec "/home/marco/src/test-monit/bin/my_alert 
'Succeeded for port 9082'"

If say ports 9080 and 9081 fail for some time, and then 9080 is again
available you might get the following entries in the call of my_alert for port 
9081:

MONIT_DESCRIPTION=connection succeeded to INET[192.168.1.1:9080] via TCP
MONIT_EVENT=Connection failed
argv[1]='Failed for port 9081'

Note that this "bug" (if that's what it is) only manifests itself in the
setting of MONIT_DESCRIPTION when an external program is called, and can
be worked around by using multiple "check host" statements.
-- 
Marco Roeland

Attachment: patch.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]