【发布时间】:2014-11-04 22:39:20
【问题描述】:
我已经通过 EPEL 存储库在全新安装的 CentOS 7 上部署了一个新的 Nagios 实例。所以 Nagios Core 版本是 3.5.1。
在安装 nagios 和 nagios-plugins-all(通过 yum)后,我创建了许多主机和服务定义,使用 nagios -v /etc/nagios/nagios.cfg 测试了我的配置,并让 Nagios 启动并运行!
很遗憾,我的主机检查失败(尽管我的服务检查工作正常)。
在 Nagios Web GUI/仪表板中,如果我深入到带有“主机状态信息”的主机页面,我会看到报告的“状态信息”(IP 地址已删除):
状态信息:/usr/bin/ping -n -U -w 30 -c 5 {my-host-ip-address}
CRITICAL - 无法解释 ping 命令的输出
所以在我的故障排除中,我深入到 Nagios 插件目录 (/usr/lib64/nagios/plugins),并使用与 check-host-alive 运行命令的方式一致的 check_ping 插件运行测试(见下文对于我的 check-host-alive 命令定义):
./check_ping -H {my-ip-address} -w 3000.0,80% -c 5000.0,100% -p 5
此 check_ping 命令返回以下输出:
PING OK - 数据包丢失 = 0%,RTA = 0.63 ms|rta=0.627000ms;3000.000000;5000.000000;0.000000 pl=0%;80;100;0
我没有更改 check_ping 工作方式的定义,并且可以确认只要以与 check-host-alive 运行命令相同的方式运行命令时我得到“PING OK”,所以我无法确定搞清楚是怎么回事!
以下是 check-host-alive 和 check_ping 的命令定义。
# 'check-host-alive' command definition
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
{snip}
# 'check_ping' command definition
define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
关于如何修复我的 check-host-alive 命令定义以正常工作并正确评估 check_ping 的输出的任何建议?
编辑
以下是我正在使用的完整定义主机 {} 模板:
define host {
host_name myers ; The name of this host template
alias Myers
address [redacted]
check_command check-host-alive
contact_groups admins
notifications_enabled 0 ; Host notifications are enabled
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
register 1
max_check_attempts 2
}
【问题讨论】:
-
你确定nagios用户可以运行ping命令了吗?
-
您为“状态信息”显示的不是它应有的样子。该输出中不应有对 /usr/bin/ping 的引用,即使失败也是如此。
-
@MrCleanX - 我读过一些博客文章,建议我检查一下。我有点担心去 chmod ping 二进制文件(这是大多数博客文章所建议的)。还有其他(更安全的)选项,例如将 Nagios 用户添加到 ping 的组或其他什么?
-
@JimBlack - 嗯,这就是我看到的错误。我已经截取了屏幕截图,并正在使用屏幕截图更新问题。
-
此主机的“定义主机”条目是什么? Nagios 似乎没有运行正确的命令。我的总是以“PING:OK...”或“PING:CRITICAL...”开头
标签: nagios