gpt4 book ai didi

Monit 检查程序返回 "no output"

转载 作者:行者123 更新时间:2023-12-03 23:54:34 25 4
gpt4 key购买 nike

我想尝试使用 monit 监控 postfix 队列。我从 Stackoverflow 的人那里举了一个例子。我的monit版本是最新的

这是 Monit 5.10 版

/etc/monit.d我有 postfixlocal

check program postfixcola with path "/usr/local/bin/postfixcola.sh"
#if status != 0 then alert
if status > 1 then alert

然后在 /usr/local/bin/我有 postfixcola.sh
#!/bin/sh
QUEUE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'`
exit $QUEUE

但是 Monit 每次都会提示脚本的输出。我之前做过测试,设置和回显 exit并且在测试时它返回了 1(因为 postfix 的队列是 1)

但错误仍然存​​在: [CET Dec 9 11:10:07] error : 'postfixcola' '/usr/local/bin/postfixcola.sh' failed with exit status (2) -- no output
我真的不知道这里有什么问题,有什么想法吗?

最佳答案

在您的 bash 脚本中,您应该在/dev/stderr 中回显一条消息:

#!/bin/bash
QUEUE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'`
if [ $QUEUE -ne 0 ] ; then
echo "Queue length > $QUEUE" > /dev/stderr
fi
exit $QUEUE

关于Monit 检查程序返回 "no output",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27376406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com