http - 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
解决方案
您似乎混淆了两个插件。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 到远程机器。
推荐阅读
- wpf - 为什么样式没有应用于 ToggleButton?
- mysql - 从 MySQL 中的 3 个表中获取所有数据
- view - Odoo v12 查找视图 ID
- json - Spring Boot Apache Kafka:ListenerExecutionFailedException 侦听器失败
- python - 在 Panda 中使用 Add() 函数合并多个数据帧
- sql - 如何在 Sybase (SAP ASE 16) 中计算数据库设备大小
- azure - 无法运行 Azure Docker 映像
- javascript - JQuery Mobile - 克隆整个正文内容
- java - 将传输结束发送到输入流
- python - 如何使用 xarray 按时间分组,然后在组上运行 bin 函数?