Disable Monit alerts when PID changed

When you monitor a process with Monit by its pid, like :

check process blop with pidfile /.../blop.pid
      start program = "..."
      stop  program = "..."

you get an alert when the pidfile is changed.

How do you disable this alert? For example, if you only want to know when the process fails to be restarted.


Solution 1:

You can disable this alert by setting up a local alert statement. This is thoroughly documented here: http://mmonit.com/monit/documentation/monit.html#setting_a_local_alert_statement

This should do it:

check process blop with pidfile /.../blop.pid
    alert [email protected] but not on { pid }
    start program = "..."
    stop  program = "..."

Solution 2:

Another option is disabling alerts on

set alert [email protected] not on { instance, action }

This way you will not receive alerts for monit restart (instance) nor alerts for all services start/stop/restart (action).

Full list of possible filters for this can be found at: https://mmonit.com/monit/documentation/monit.html#Setting-an-event-filter (I think this list should also apply to the alerts attached to process checks of another answer for this question).