首页 > 解决方案 > Nagios 警报返回“NRPE:无法读取输出”命令:check_service!httpd

问题描述

我在 Redhat 上安装了 Nagios,配置如下:

/usr/local/nagios/etc/static/commands.cfg
define command {
       command_name                     check_service
       command_line                     $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_service -a $ARG1$
}

当我尝试手动运行它时:

if i try to use the following syntax, I get error:

/usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -c check_service -a check_http
NRPE: Unable to read output

不使用不:

/usr/local/nagios/libexec/check_http -H 10.111.55.92
HTTP OK: HTTP/1.1 200 OK - 4298 bytes in 0.024 second response time |time=0.024462s;;;0.000000 size=4298B;;;0

我不断收到 Nagios 电子邮件通知:

HOST: Proxy (Dev) i-01aa24242424d7
IP: 10.111.55.92
Service: Apache Running
Service State: UNKNOWN
Attempts: 3/3
Duration: 0d 9h 28m 49s
Command: check_service!httpd
\More Details:
NRPE: Unable to read output

不知道如何使用 nrpe 和 check_service 来检查 http

只是。使用 check_http 运行 check_nrpe 会显示已安装 nope 的版本

/usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -a check_http
NRPE v3.2.1

/usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 10 -c 15
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_root_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 10 -c 15 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 750
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 750
command[check_ping]=/usr/local/nagios/libexec/check_ping $ARG1$
command[check_http]=/usr/local/nagios/libexec/check_http

# LINUX DEFAULT
command[check_service]=/bin/sudo -n /bin/systemctl status -l $ARG1$

# GLUSTER CHECKS
command[check_glusterdata]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /gluster

# GITLAB CHECKS
command[gitlab_ctl]=/bin/sudo -n /bin/gitlab-ctl status $ARG1$
command[gitlab_rake]=/bin/sudo -n /bin/gitlab-rake gitlab:check
command[check_gitlabdata]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /var/opt/gitlab

# OPENSHIFT CHECKS
command[check_openshift_pods]=/usr/local/nagios/libexec/check_pods

文件:/usr/local/nagios/etc/nagios.cfg

cfg_dir=/usr/local/nagios/etc/static

标签: httpnagiosxi

解决方案


您似乎混淆了两个插件。check_service 只会检查服务是否在本地运行。尝试这样称呼它:

/usr/local/nagios/libexec/check_nrpe -H 10.111.55.92 -c check_service -a httpd

不过,我会犹豫是否使用您在其中的 check_service 命令。授予 nrpe 访问权限以使用 sudo 运行 systemctl 对我来说似乎很危险。

check_http 是一个 http 客户端。它实际上会连接到一个 http 服务器并检查给定的 URI。它可以检查状态代码并执行各种操作。

看起来在您的 nrpe.cfg 中您没有包含任何 check_http 参数。如果你这样称呼它,它只会打印它的帮助信息,我认为它不会检查本地机器。

请注意,当您手动调用上面的 check_http 时,您提供 -H。-H 不会自动传递,您需要在 nrpe.cfg 中为您的 check_http 命令提供参数。

换行:

命令[check_http]=/usr/local/nagios/libexec/check_http

类似于:

命令[check_http]=/usr/local/nagios/libexec/check_http -H 127.0.0.1

假设您的 http 正在侦听本地主机,它应该会更好地工作。

不过,您可能不想像这样通过 nrpe 调用 check_http 。让你的 nagios 服务器调用 check_http 到远程机器。


推荐阅读