在监控中采取两个行动

Odd*_*ing 4 monitoring monit

我的 monit 脚本用于检测进程中断并在规则为时通知我:

  IF DOES NOT EXIST THEN ALERT
Run Code Online (Sandbox Code Playgroud)

我的 monit 脚本用于检测中断并在规则为时自动修复它:

  IF DOES NOT EXIST THEN START
Run Code Online (Sandbox Code Playgroud)

但是,我想要它做的是通知我并修复它

连续两条规则似乎使它忽略了除最后一条之外的所有规则:

  IF DOES NOT EXIST THEN ALERT
  IF DOES NOT EXIST THEN START
  # No alert given.
Run Code Online (Sandbox Code Playgroud)

我可以使用一个自定义脚本来做这两个,并且

  IF DOES NOT EXIST THEN EXEC "my_handwritten_script"
Run Code Online (Sandbox Code Playgroud)

但我试图从一堆手写脚本转向干净的 Monit 配置。

我可以将 Monit 配置为采取两项行动吗?

eww*_*ite 6

默认情况下,Monit 会在执行操作时向您发送一封电子邮件。

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
Run Code Online (Sandbox Code Playgroud)

此服务的我的 Monit 配置:

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
Run Code Online (Sandbox Code Playgroud)