【问题标题】:Is there a way to pass Environment variables through a Monit config有没有办法通过 Monit 配置传递环境变量
【发布时间】:2019-04-04 14:38:17
【问题描述】:

我有一个脚本需要 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

【问题讨论】:

    标签: monit


    【解决方案1】:

    无法使用 monit 将 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
    

    【讨论】:

      猜你喜欢
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-25
      • 2018-07-13
      相关资源
      最近更新 更多