1

I'd like to customize an alert message for the following condition:

if cpu > 75% for 2 cycles then exec "command|mail -s subject test@example.com"

to monitrc config file

how can I add that command?

  check process apache with pidfile /var/run/apache2.pid
    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
    stop program  = "/etc/init.d/apache2 stop"
    if cpu > 60% for 2 cycles then alert
    if cpu > 80% for 5 cycles then restart      # 10minutes
    if totalmem > 200.0 MB for 5 cycles then restart
    if children > 250 then restart
    if loadavg(5min) greater than 10 for 8 cycles then stop
    if failed host 192.168.1.200 port 80 protocol http 
       and request "/monit/token"
       then restart

Why if I add that line no email is sent when condition is met? Any ideas?

  • Is there anything useful in monit's log file? – Paul Haldane Nov 11 '14 at 8:06
0

Put the command inside a shellscript

if cpu > 75% for 2 cycles then exec "/full/path/custom_email.sh"

Then /full/path/custom_email.sh would contain something like

#!/bin/bash
command|mail -s subject test@example.com
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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