【问题标题】:How to output stdout and stderr from an exec program script in monit如何从monit中的exec程序脚本输出stdout和stderr
【发布时间】:2016-02-08 18:07:07
【问题描述】:

我有一个 python 脚本,我用它来检查某些系统条件,以便在使用 monit 时发出警报。 该脚本在执行期间将大量内容打印到我想在日志文件中捕获的标准输出。 我应该如何配置 monit conf 脚本,以便我可以捕获该脚本的 stdout 和 stderr 并同时警告脚本的退出状态。监控警报还应包括警报事件的标准输出/标准错误。

这是我尝试过的

#/etc/monit/conf/myprogram.conf

check program my_program with path "/usr/bin/python -u /opt/program/my_program.py > my_prgoram.log 2&>1"
 if status !=0 alert

但我看到监视器总是认为程序正在报告 status=0,即使它存在错误代码 1。

我做错了什么?

【问题讨论】:

    标签: monit


    【解决方案1】:

    $MONIT_DESCRIPTION 包含标准错误

    【讨论】:

      【解决方案2】:

      试试这个:

      #/etc/monit/conf/myprogram.conf
      
      check program my_program with path "/bin/bash -c '/usr/bin/python -u /opt/program/my_program.py > my_prgoram.log 2&>1'"
       if status !=0 alert
      

      【讨论】:

        猜你喜欢
        • 2021-05-26
        • 2013-09-22
        • 1970-01-01
        • 2016-12-21
        • 1970-01-01
        • 2010-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多