Monit only executing once

泄露秘密 提交于 2020-01-25 09:30:10

问题


Monit is currently executing once. I can see in the log file that it does a check every cycle, however, the execution only happens once when I reload monit.

check host somehost with address example.com
# every "* 8-19 * * 1-5"
 if failed
    port 443
    protocol https
    and certificate valid > 1095 days
 then exec "/var/local/bin/mtCert.sh"

回答1:


Monit is based on triggers, it basically only tracks changes.

So if the configured state is not changing, monit will not trigger the script again by default. See note on 5.16.0 at Monit Changelog:

Fixed: The exec action is now executed only once on state change, the same way as the alert action. The new repeat option can be used to repeat the exec action after a given number of cycles if the error persists. Syntax:

if <test> then exec <script> [repeat every [x] cycle(s)]

If you want the old behaviour, use "repeat every cycle". Example:

if failed port 1234 then exec "/usr/bin/myscript.sh" repeat every cycle

So if you in fact need the script to be called multiple times, just add the repeat:

check host somehost with address example.com
# every "* 8-19 * * 1-5"
  if failed
    port 443
    protocol https
    and certificate valid > 1095 days
  then exec "/var/local/bin/mtCert.sh"
  and repeat every 10 cycles


来源:https://stackoverflow.com/questions/56011030/monit-only-executing-once

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!