Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
monit should alert anyway when it starts something. –  Mike Aug 30 '12 at 3:14
    
Please show your Monit config... –  ewwhite Aug 30 '12 at 3:16
add comment

1 Answer

up vote 4 down vote accepted

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
share|improve this answer
    
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 3:52
    
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 4:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.