【问题标题】:how to monitor crond service in nagios如何在 nagios 中监控 crond 服务
【发布时间】:2015-08-26 07:12:38
【问题描述】:

我想监控 Nagios 中的 crond 服务。

我尝试使用创建下面的脚本并放在/usr/local/nagios/libexec/

CRON_RESULT=$(/etc/init.d/crond status)
STATUS=`echo $CRON_RESULT| grep pid`
if [ -z "$STATUS" ]; then
        echo "CROND CRITICAL- $CRON_RESULT"
        exit 2
else
        echo "CROND OK- $CRON_RESULT"
        exit 0
fi

如果没有 cron 正在运行(显示 CRITICAL)并且如果正在运行(显示 OK),则它工作正常。

但如果 NRPE 客户端无法从 Nagios 服务器访问,crond 服务会显示状态为“OK”(绿色)并显示消息 return code of 255 is out of bounds。而且我无法知道 crond 是否正在运行。

在 CentOS 6.6 中还有其他方法可以监控 crond 服务吗?

【问题讨论】:

    标签: centos nagios nrpe


    【解决方案1】:

    从 Nagios 服务器上的 libexec 目录中,针对包含要监视的 crond 服务的主机的 IP 地址手动执行 check_nrpe 命令:

    [root@joeyoung.io libexec]# pwd
    /usr/local/nagios/libexec
    [root@joeyoung.io libexec]# ./check_nrpe -H 10.0.0.1
    connect to address 10.0.0.1 port 5666: No route to host
    

    运行check_nrpe后,立即执行echo $?获取返回码。

    [root@joeyoung.io libexec]# echo $?
    255
    

    如果您得到255(或0 以外的任何数字)的结果,那么您收到的手动执行check_nrpe 的错误消息是问题根源的症状。

    您可以尝试运行此程序并返回报告吗?

    【讨论】:

    • 是的,它是相同的 255 错误代码,但这是否意味着我必须编辑 nrpe 文件?我搜索并发现它是 nrpe2.15 中的错误,因此在 Nagios 服务器上恢复到 nrpe2.12 解决了我的问题。感谢您的回复。
    • 降级到 2.12 后问题解决了吗?如果没有,您能否发布手动 check_nrpe 错误消息的完整输出?
    【解决方案2】:

    我搜索并发现它是 nrpe v2.15 中的错误,所以我在 Nagios 服务器上恢复到 nrpe v2.12 并解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多