Search code examples
monit

File checks in monit not working


I have very simple script in monit:

check file reload_nginx with path /srv/www/site/shared/pids/reload_nginx
if not exist then exec "/bin/bash -c 'echo \"OK\"'" else if succeeded then exec "/bin/bash -c 'service nginx reload; rm /srv/www/site/shared/pids/reload_nginx'"

Monit shows that it's in "accessible" state. But script does ... nothing. File still exists on that path. No messages in syslog.

I've tried to change exec to alerts and echos - and still received nothing. I can't even say, whether checks are performed or not.

How to deal with it?


Solution

  • So, ok, i found the answer.

    [if succeeded] branch in monit executed only when state of check CHANGED from "Failed" to "Succeeded". If check is succeeded at the start of monitoring - that branch wan't be called.