Monit似乎放弃了重启服务,如果它几次失败,并取消它的监视。 在关于何时或为什么的细节的文档中,我找不到任何东西。
我的Monitconfiguration设置如下:
set daemon 10 set logfile /var/log/monit.log set statefile /var/lib/monit/monit.state set alert [email protected] not { nonexist, action, instance } include /etc/monit/conf.d/*
这是我正在使用的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
在我的环境中,我希望它无限期地继续尝试其轮询间隔。 有没有什么办法可以configuration监控, 永不停止监控服务,即使它不能成功启动?
我只是简单地使用一个cron作业,以期望的时间间隔运行monit start servicename 。 当然,你可以使用组进行更好的控制。
我有完全相同的问题,尽pipe重新启动监视,它会拒绝监视超时。 最后想出了必须删除监视状态文件( /var/.monit.state )并重新启动监视,使其再次监视所有程序。
在做了一些挖掘之后,Monit将系统监控数据存储在“状态”文件中。 这个“状态”文件跟踪什么服务被监视/不监视。
所以虽然这有点“蛮力”,但它确实有效。 如果服务由于超时等原因而变成“不受监控”,那么只需从系统中删除Monit状态文件,如下所示:
sudo rm /var/lib/monit/state
然后重新启动Monit这样,所有应该是好的:
sudo service monit restart
根据您的Monit代码片段,您似乎必须修改或添加循环语句到您的stream程节。 见这里和这里的相关文件 。
似乎你可能想要设置你的服务testing执行每个周期没有超时声明。 另外看看你的监控主页http:// hostname:2812 . Check the page for the relevant service and look at . Check the page for the relevant service and look at “存在”字段。 你的默认应该是这样的:
If doesn't exist 1 times within 1 cycle(s) then restart else if succeeded 1 times within 1 cycle(s) then alert