[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [monit-dev] [PATCH] Pass correct MONIT_DESCRIPTION env variable for
From: |
Jan-Henrik Haukeland |
Subject: |
Re: [monit-dev] [PATCH] Pass correct MONIT_DESCRIPTION env variable for external program |
Date: |
Sat, 24 Jul 2010 01:19:22 +0200 |
Hi Marco
Thank you very much for the patch. That looks like a minor bug yes. Your patch
looks fine, though we'll discuss if there are other ways to resolve the problem
or if we will apply the patch.
Thanks again.
Jan-Henrik
On Jul 23, 2010, at 1:46 PM, Marco Roeland wrote:
> 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