【发布时间】:2016-10-25 12:28:56
【问题描述】:
我有一个使用 Monit 监控的进程。如果进程由于某种原因而死,我想使用 shell 脚本发送 Slack 通知并重新启动它。这种行为虽然不适用于“不存在”指令。最后一个被执行,前一个被忽略。例如下面的代码:
check process xyz with pidfile /var/run/xyz.pid
start program = "/etc/init.d/xyz start" with timeout 60 seconds
stop program = "/etc/init.d/xyz stop"
if does not exist then restart
if does not exist then exec "/opt/somescript.sh"
它执行脚本但不重新启动。从文档中也可以看出它的行为方式。任何其他方式来得到这个工作。文档参考(不完全清楚,但类似于实际行为):
If not defined, it defaults to a restart action.
You can override the default action with the following statement:
【问题讨论】:
标签: monitoring monit