我在成功执行脚本时遇到问题。
~/.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"
如果出现错误,它似乎会运行脚本,但在没有错误时不会运行。
日志显示测试已运行并成功,/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
我检查了运行是否/usr/local/bin/monit_example_ok.sh
按预期工作(在相关目录中创建相关状态文件)。
操作系统:
% 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
监控:
ii monit 1:5.6-2 amd64 utility for monitoring and managing daemons or similar progra
成功操作仅在失败事件解决后(即从状态失败到状态成功时)执行,而不是在事情按预期运行时执行。