我想为以下情况自定义警报消息:
if cpu > 75% for 2 cycles then exec "command|mail -s subject [email protected]"
到monitrcconfiguration文件
我怎样才能添加该命令?
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
为什么如果我添加该行,条件满足时不发送电子邮件? 有任何想法吗?
把这个命令放在一个shell脚本里面
if cpu > 75% for 2 cycles then exec "/full/path/custom_email.sh"
然后/full/path/custom_email.sh会包含类似的东西
#!/bin/bash command|mail -s subject [email protected]