我有一个脚本,需要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
答案 0 :(得分:0)
无法通过监视将ENV
传递给脚本。
最简单的方法可能是使用参数:
添加桥脚本 /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