2

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?

Marco
  • 1,679
  • 3
  • 17
  • 31
watchmansky
  • 749
  • 4
  • 9
  • 16

1 Answers1

1

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