monit - 有没有办法通过 Monit 配置传递环境变量
问题描述
我有一个脚本需要 Monit 保持活力。如何将我的环境变量传递给这个脚本?就像是:
check host steve with address localhost
group nn
ENV = "DBHOST=localhost" #this doesn't work...
start program = "/home/steve.sh start"
start program = "/home/steve.sh restart"
if failed port 80 protocol http for 2 cycles then restart
解决方案
无法ENV
使用 monit 传递给脚本。
完成此操作的最简单方法可能是使用参数:
添加桥接脚本 /home/monit_steve.sh
:
#!/bin/bash
export DBHOST="$1"
/home/steve.sh "$2"
exit $?
然后更新你monitrc
的匹配(你目前有 2x start program
...):
check host steve with address localhost
group nn
start program = "/home/monit_steve.sh localhost start"
restart program = "/home/monit_steve.sh localhost restart"
if failed port 80 protocol http for 2 cycles then restart
推荐阅读
- excel - Google 表格公式替换 Excel 公式查找(2,1/(AA:AA<>""),AA:AA)
- mysql - 如何通过语句转换订单中的日期?(MySQL)
- python - 直方图均衡给了我全黑的图像
- asp.net-core - 如何在 Blazor Server 关闭之前执行方法?
- sql-server - 由于区分大小写,Tablediff 实用程序未创建文件
- phaser-framework - 调试对象未定义
- vba - 为什么我在一个表单上而不是另一个表单上收到运行时错误 2185?
- excel - 在excel选择中交换2个值
- visual-studio - 在 Visual Studio 中重定向生成输出
- python - 为什么我需要在 Python/Pytorch 中使用两次导入?