4

My monit script works to detect an outage with a process and inform me when the rule is:

  IF DOES NOT EXIST THEN ALERT

My monit script works to detect an outage and automatically fix it when the rule is:

  IF DOES NOT EXIST THEN START

But, what I want it to do is inform me AND fix it.

Two rules in a row seems to make it ignore all but the last:

  IF DOES NOT EXIST THEN ALERT
  IF DOES NOT EXIST THEN START
  # No alert given.

I could use a custom script that does both, and

  IF DOES NOT EXIST THEN EXEC "my_handwritten_script"

but I was trying to move away from a mess of hand-written scripts towards a clean Monit configuration.

Can I configure Monit to take two actions?

ewwhite
  • 194,921
  • 91
  • 434
  • 799
Oddthinking
  • 262
  • 2
  • 15

1 Answers1

6

Monit should send you an email by default when it takes an action.

Does not exist Service atd

    Date:        Thu, 03 May 2012 14:37:19 -0400
    Action:      restart
    Host:        abc.xyzgroup.com
    Description: process is not running

Your faithful employee,
Monit

My Monit config for this service:

check process atd
        with pidfile "/var/run/atd.pid"
        start program = "/sbin/service atd start"
        stop program = "/sbin/service atd stop"
        if 10 restarts within 11 cycles then timeout
        if cpu usage > 95% for 11 cycles then restart
ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • I've been following this up since @Mike's comment. Looks like ALL outgoing emails are being lost since I last tested it with an alert... so monit's not to blame. Still checking what's really going on. Sigh, if only I had a monitoring tool to check for this... :-) – Oddthinking Aug 30 '12 at 03:52
  • 1
    The problem *appears to be that Gmail changed its mind, and no longer likes "monit@server1" as the FROM address. Alerts (which had been getting through) stopped when I made unrelated changes to the monit config. I went and researched the MAIL-FORMAT setting, changed the FROM address, and the alerts are now getting through again. – Oddthinking Aug 30 '12 at 04:29