监视“检查程序”不遵守警报条件

问题描述

我试图使用monit在每个周期中运行一个脚本,并仅在N次连续失败后才报告syslog中的错误

例如

check program TestScript with path "/usr/local/bin/test_script.py"
    if status != 0 for 5 times within 5 cycles then alert

我故意使脚本在每次调用时都以非零值退出模拟一致的故障

上面的配置为每个周期引发警报(暗指在syslog中写入ERR消息),而不是等待5个周期,然后引发警报。

也尝试了以下“ if”子句。

check program TestScript with path "/usr/local/bin/test_script.py"
    if status != 0 for 10 times within 20 cycles then alert

check program TestScript with path "/usr/local/bin/test_script.py"
    if status = 1 for 3 cycles then alert

check program TestScript with path "/usr/local/bin/test_script.py"
    if status != 0 for 5 times within 5 cycles then alert

check program TestScript with path "/usr/local/bin/test_script.py"
    if status != 0 for 5 times within 5 cycles then exec “/tmp/t.sh”

有趣的是,最后一个变体(甚至没有单词“ alert”而是“ exec”)在每个周期中仍会在syslog中以ERR消息形式发出警报。

停止警报的唯一方法是没有“ if”子句或“ if”子句不匹配。

任何帮助解决此问题的技巧都是 big 帮助。

提前谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)