monit - 监控只执行一次
问题描述
Monit 当前正在执行一次。我可以在日志文件中看到它每个周期都会检查一次,但是,当我重新加载 monit 时,执行只会发生一次。
check host somehost with address example.com
# every "* 8-19 * * 1-5"
if failed
port 443
protocol https
and certificate valid > 1095 days
then exec "/var/local/bin/mtCert.sh"
解决方案
基于Monit triggers
,它基本上只跟踪变化。
所以如果配置的状态没有改变,monit默认不会再次触发脚本。请参阅 Monit Changelog中有关 5.16.0 的注释:
已修复: exec 操作现在只在状态更改时执行一次,与警报操作相同。如果错误仍然存在,新的重复选项可用于在给定数量的周期后重复执行操作。句法:
if <test> then exec <script> [repeat every [x] cycle(s)]
如果您想要旧的行为,请使用“重复每个循环”。例子:
if failed port 1234 then exec "/usr/bin/myscript.sh" repeat every cycle
因此,如果您实际上需要多次调用脚本,只需添加repeat
:
check host somehost with address example.com
# every "* 8-19 * * 1-5"
if failed
port 443
protocol https
and certificate valid > 1095 days
then exec "/var/local/bin/mtCert.sh"
and repeat every 10 cycles
推荐阅读
- html - 为什么页面源不更新以显示页面响应?
- javascript - Ember 组件不会在路由重新加载或 transitionTo 时重新加载
- firebase - 无法将firestorage的url字符串添加到firestore
- android - 在c ++中将角度的正弦作为双精度数
- c# - C# WSDL 返回 XML 响应,但变量仍然为空
- azure - FFmpeg 命令在本地工作,但不适用于 Azure Batch Service
- python - Python 多处理数百个文件
- php - 为什么 PHP 中的 DEFINE 可以接受随机值?
- php - 如何在 Outlook 365 中将 imap_open() 用于组
- sql-server - 部署 DACPAC 是否需要将数据库注册为 DAC?