monit 仅在 x 为真时执行 y

monit only exec y if x is true

我正在尝试使用 monit 来监控 Confluence 实例。

check process catalina with pidfile /usr/local/Confluence/work/catalina.pid
   start program = "/etc/init.d/confluence start"
   stop program = "/etc/init.d/confluence stop"
   if does not exist then
   ...
   if failed host confluence.dev.opt port 80 protocol http then
   ...
   else if succeeded then
   ...

这些 if 语句中的每一个都调用一个单独的 bash 脚本来将 curl 请求发送到状态页面,该状态页面将电子邮件更新发送给所述页面的订阅者。

有时,catalina.pid 可以存在其中的 pid 值,但没有人可以连接,就好像进程已经过时一样。但是,如果 confluence pid 实际上丢失了,那么第一次和第二次检查都将失败,第三次检查将被执行两次,从而导致执行 4 个单独的 curl 请求,从而导致垃圾邮件。

有什么办法只能在第一次检查通过后才执行第二次检查?

您可以使用 depends on 语句 https://mmonit.com/monit/documentation/monit.html#SERVICE-DEPENDENCIES

还要确保将支票分成小支票。