Nagios Alert返回“ NRPE:无法读取输出”命令:check_service!httpd

时间:2019-06-17 22:48:53

标签: http nagiosxi

我已经在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

不使用nope:

/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

1 个答案:

答案 0 :(得分:1)

您似乎在混淆两个插件。 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命令提供参数。

更改行:

command [check_http] = / usr / local / nagios / libexec / check_http

类似:

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

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

您可能不想像这样通过nrpe调用check_http。让您的nagios服务器将check_http呼叫到远程计算机。