1

I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit. I want to run a script before the running the restart command. I have used the below conditions for the same.

if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

if does not exist for 10 cycles then restart

Unfortunately only the restart action is getting executed.

Can anyone please help me to identify why the first rule is not executed ? Is there are any other way to solve the problem ?

Supratik
  • 2,104
  • 10
  • 49
  • 66

1 Answers1

0

This is not a definitive answer, as I am a newbie currently chasing down a similar problem.

I currently have a suspicion that the last rule overrides all previous rules.

If so, try:

if does not exist for 2 times within 3 cycles 
then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser 
ELSE if does not exist for 10 cycles then restart
Oddthinking
  • 262
  • 2
  • 15