If checking for succeded the alert messages are swapped

Issue #1057 closed
codiflow created an issue

I use monit 5.32.0 and M/Monit for monitoring the availability of a host in my network.

So the check rule in .monitrc is as follows:

check host MYHOST with address 192.168.1.2
if succeeded ping then alert

In M/Monit I have two alert rules which trigger a notification for both events “failed / changed” and “succeeded” independently. They look like this:

ANY SERVICE SUCCEEDED

/root/telegram-notify-monit.sh "✅ MONITORING ✅
$MONIT_DATE

$MONIT_EVENT
$MONIT_SERVICE"

ANY SERVICE FAILED / CHANGED

/root/telegram-notify-monit.sh "⚠ MONITORING ⚠
$MONIT_DATE

$MONIT_EVENT
$MONIT_SERVICE"

Now as soon as the host becomes available (succeeded) I get the following message via Telegram:

And as soon as the host is not available anymore (failed / changed) the message looks like this:

My expectation would be that the alert messages appear the other way round because I check for the condition “if succeeded” and not “if failed”.

In M/Monit everything behaves like it should (shows online with all services while being not available):

Comments (5)

  1. codiflow reporter

    The respective emails sent by m/monit contain the following:

    and

    There you can see the difference between the email subject and the content of the “Description” field which matches my expectations.

  2. Henning Bopp

    Standard monit config always is a description of fail states. (Yes, there are exceptions, but it's true as a rule-of-thumb)

    So as your config states

    if succeeded ping then alert
    

    it tells monit to alert (aka fail) if the ping succeeds. So this check would make sense if there is a device in your network that should not be available via ICMP. If the failed state should trigger if the host is not available, you need to

    if failed ping then alert
    
  3. codiflow reporter

    Thanks Henning for pointing that out – so I have to live with it 😎.

    The main problem with changing the check to the one you mentioned would be that the monitoring host would stay in “warning” state (yellow symbol) as long as the machine is not available. I would like to prevent that because the default is that the host is not available. That's why this default state (ping not successful) should lead to a non-warning state of the monitoring host (green symbol) and because of that I’ve choosen the other kind of check.

  4. Log in to comment