3

I have monit installed on some user laptops/desktop so it can make sure a couple processes are always running/get restarted as needed. But since the devices are regularly shutdown/restarted I frequently receive a message like below which I do not want or care about, since they are telling me that the system was restarted. I want to suppress the messages that seem to automatically happen when monit starts/stops.

Subject: monit alert -- Monit instance changed

Service     - system_slaveone
Event       - Monit instance changed
Action      - start
Date        - Thu, 18 Apr 2013 07:53:51
Host        - slaveone.example.local (slaveone)
Description - Monit started.

But once the system is up, I do want to get some alerts about a couple services/resources that I do want to be notified about, so simply disabling email isn't want I want to do.

How can I suppress the message on startup/restart without completely disabling email?

1
  • Desirable feature on a server. Not so much on a workstation.
    – ewwhite
    Apr 18, 2013 at 20:35

2 Answers 2

2
+50

Oh, sure...

To suppress Monit alerts for a particular check, you need to use the noalert directive.

For instance, I can have a check for the cron daemon, which restarts weekly. Maybe I don't want that email in my inbox every Sunday...

check process cron
    noalert [email protected]
    with pidfile "/var/run/crond.pid"
    start program = "/sbin/service crond start"
    stop program = "/sbin/service crond stop"

This works for any Monit check, so to handle the instance alarms for the system, you can suppress by adding the noalert under the check system localhost entry:

  check system localhost
    noalert [email protected]

Try it. This still leaves any real services/daemons under Monit protection, but reduces the chatter. Great for misbehaving applications...

check process nslcd
        with pidfile "/var/run/nslcd/nslcd.pid" every 2 cycles
        noalert ewwhite@bra**ers.com
        start program = "/sbin/service nslcd start"
        stop program = "/sbin/service nslcd stop"
        if 10 restarts within 11 cycles then timeout
        if cpu usage > 95% for 11 cycles then restart
        if totalmemory > 128 MB then restart
5
  • Applying the alert configuration to the check system localhost is what I was looking for. I must have missed that in the man page.
    – Zoredache
    Apr 29, 2013 at 21:30
  • 1
    It's not well documented. I had to experiment on my own 6 months ago to find it. Bummer is that you have to specify the exact mail addresses to be excluded.
    – ewwhite
    Apr 29, 2013 at 21:34
  • But won't that disable all cron alerts, not just the expected weekly restart?
    – Johan
    Sep 1, 2014 at 9:54
  • @Johan Nope....
    – ewwhite
    Sep 1, 2014 at 12:20
  • How does monit know the noalert only applies to the weekly restart, not an unexpected problem during the week? What've I missed?
    – Johan
    Sep 2, 2014 at 13:48
8

To particularly filter out the e-mails when monit starts/stops, you can use the instance event filter:

set alert [email protected] not on { instance }

As in the documentation:

Event:     | Failure state:            | Success state:              
---------------------------------------------------------------------
...
INSTANCE   | "Monit instance changed"  | "Monit instance changed not"
...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .