可以将 Monit 配置为从不取消监视/超时服务吗?

Joe*_*haw 8 linux monitoring monit

如果服务失败几次,Monit 似乎会放弃重新启动服务,并取消对其进行监控。我在文档中找不到任何关于时间或原因的细节。

我的 Monit 配置将设置如下:

set daemon 10
set logfile /var/log/monit.log
set statefile /var/lib/monit/monit.state
set alert foo@example.com not { nonexist, action, instance }
include /etc/monit/conf.d/*
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的 Monit 规则集的示例:

check process myservice
  with pidfile /var/run/myservice/myservice.pid
  start program = "/home/myservice/current/start-myservice.sh"
    as uid myservice and gid myservice
  stop program = "/home/myservice/current/stop-myservice.sh"
    as uid myservice and gid myservice
  mode active
Run Code Online (Sandbox Code Playgroud)

在我的环境中,我希望它无限期地继续尝试轮询间隔。有没有办法将 monit 配置为从不停止监视服务,即使它没有成功启动?

ale*_*rul 5

我会简单地使用一个monit start servicename按所需时间间隔运行的 cron 作业。当然,您可以使用组进行更精细的控制。

  • 这正是我最终要做的,但我对此并不高兴。 (2认同)

eww*_*ite 1

根据您的 Monit 代码片段,您似乎必须在流程节中修改或添加循环语句。请参阅此处此处的相关文档。

看来您可能希望将服务测试设置为在没有超时语句的情况下执行每个周期。另请查看您的 monit 主页http://hostname:2812 的. Check the page for the relevant service and look at“Existence”字段。您的默认值应如下所示:

If doesn't exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert
Run Code Online (Sandbox Code Playgroud)