I have a problem with monit executing script on success.
~/.monitrc
:
check host example.com with address example.com
if failed url http://example.com/startpage and content == "mainBaner"
timeout 10 seconds
then exec "/usr/local/bin/monit_example_error.sh"
else if succeeded then exec "/usr/local/bin/monit_example_ok.sh"
It appears to run the script if there's an error, but not when there's no error.
Log shows that the tests are ran and succeed, /var/log/monit.log
:
[CEST Jun 8 12:24:52] debug : 'example.com' succeeded testing protocol [HTTP] at INET[example.com:80/startpage] via TCP
[CEST Jun 8 12:25:22] debug : 'example.com' succeeded connecting to INET[example.com:80/dlibra] via TCP
[CEST Jun 8 12:25:46] debug : HTTP: Regular expression matches
[CEST Jun 8 12:25:46] debug : 'example.com' succeeded testing protocol [HTTP] at INET[example.com:80/startpage] via TCP
[CEST Jun 8 12:26:16] debug : 'example.com' succeeded connecting to INET[example.com:80/dlibra] via TCP
[CEST Jun 8 12:26:39] debug : HTTP: Regular expression matches
I have checked that running /usr/local/bin/monit_example_ok.sh
works as expected (creating relevant status file in relevant dir).
OS:
% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
% uname -a
Linux ql 3.13.0-119-generic #166-Ubuntu SMP Wed May 3 12:18:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Monit:
ii monit 1:5.6-2 amd64 utility for monitoring and managing daemons or similar progra