我想在monit中处理一种链式行动。
- 检查进程并立即发出警报。
- 在若干周期后重新启动进程。
我的尝试(到目前为止):
check process myprocess with pidfile /run/my.pid
start program = "/path/to/binary start" with timeout 60 seconds
stop program = "/path/to/binary stop" with timeout 60 seconds
if not exist for 3 cycles then restart
if not exist then alert
if 3 restarts within 3 cycles then timeout
即使PID失败也不会发出警报并保持“running”状态,但在3个周期后将重新启动。
check process myprocess with pidfile /run/my.pid
start program = "/path/to/binary start" with timeout 60 seconds
stop program = "/path/to/binary stop" with timeout 60 seconds
if not exist for 3 cycles then restart
if children < 1 for 1 cycles then alert
if 3 restarts within 3 cycles then timeout
没有1岁以下儿童的警报,但在5秒后重新启动。 monit.log
[CEST Aug 1 15:09:30] error : 'myprocess' process is not running
Monit 概述
Process 'myprocess' Running
这里是monit -v的部分:
Existence = if does not exist 3 times within 3 cycle(s) then restart else
if succeeded 1 times within 1 cycle(s) then alert
Pid = if changed 1 times within 1 cycle(s) then alert
Ppid = if changed 1 times within 1 cycle(s) then alert
Children = if less than 1 1 times within 1 cycle(s) then alert else if
succeeded 1 times within 1 cycle(s) then alert
Timeout = If restarted 3 times within 3 cycle(s) then unmonitor
问题是:是否可以在1个周期内发送警报并更改状态为“未运行”,然后在3个周期后重新启动?