Search code examples
monit

Application failed to start after timestamp check failed in monit


I am having a simple monit control file which contains the following

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

Here the intention is to restart fooBar, fooBar1 and fooBar2 applications when the timestamp check for checkFile fails. But what actually happens is it tries to restart the checkFile instead of fooBar.

This check was working fine with monit version 5.5, but not working with 5.18.

This is what I am getting when timestamp fails and after that 8 cycles are elapsed.

'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

Am I missing something here? Thanks in advance


Solution

  • Tried with a work around,

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

    This is restarting application fooBar every cycle when timestamp check fails. But just wondering any other better way to do it?