monit中的时间戳检查失败后,应用程序无法启动

时间:2017-12-12 09:47:56

标签: monit

我有一个简单的监控文件,其中包含以下内容

check process fooBar1 with pidfile fooBar1PidFile
   start program = "/etc/init.d/fooBar1 start" with timeout 10 seconds
   stop program = "/etc/init.d/fooBar1 stop"
   if 5 restarts within 5 cycles then unmonitor

check process fooBar2 with pidfile fooBar2PidFile
   start program = "/etc/init.d/fooBar2 start" with timeout 10 seconds
   stop program = "/etc/init.d/fooBar2 stop"
   if 5 restarts within 5 cycles then unmonitor

check process fooBar with pidfile fooBarPidFile
   start program = "/etc/init.d/fooBar start" with timeout 10 seconds
   stop program = "/etc/init.d/fooBar stop"
   if 5 restarts within 5 cycles then unmonitor
   if memory usage > 25.0 MB for 4 cycles then alert
   depends on fooBar1
   depends on fooBar2
   depends on checkFile


check file checkFile with path pathToFile
   if timestamp > 4 minute for 8 cycles then restart

此处的目的是在fooBar的时间戳检查失败时重新启动fooBar1fooBar2checkFile个应用程序。但实际发生的是它尝试重新启动checkFile而不是fooBar

这项检查在monit 5.5版中运行正常,但不能与5.18一起使用。

这是我在时间戳失败时以及经过8个周期后得到的结果。

'checkFile' timestamp for pathToFile failed -- current timestamp is Fri, 08 Dec 2017 12:47:04
'fooBar' failed to start -- could not start required services: 'checkFile'
'fooBar' start action failed

我在这里遗漏了什么吗? 提前致谢

1 个答案:

答案 0 :(得分:0)

尝试了解决方法,

check file checkFile with path pathToFile
    if timestamp > 4 minute for 8 cycles then
    exec "/etc/init.d/fooBar restart"
    repeat every 1 cycles

这是在时间戳检查失败时每个周期重新启动应用程序fooBar。但只是想知道还有其他更好的方法吗?