我在 monit 执行脚本时遇到问题成功。
~/.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
答案1
成功操作仅在失败事件已解决(即从状态失败陈述成功),而不是当事情按照预期发展时。