有没有办法通过Monit配置传递环境变量

时间:2019-04-04 14:38:18

标签: 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

1 个答案:

答案 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
相关问题