Nagios监控主机,带有check_ping

Dav*_*d W 1 nagios

我已经通过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}

严重-无法解释ping命令的输出

在此处输入图片说明

因此,在故障排除中,我深入到了Nagios插件目录(/ usr / lib64 / nagios / plugins),并使用与check_host-alive运行命令的方式一致的check_ping插件进行了测试(请参阅下面的检查内容-host-alive命令定义):

./check_ping -H {my-ip-address} -w 3000.0,80% -c 5000.0,100% -p 5
Run Code Online (Sandbox Code Playgroud)

此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
        }
Run Code Online (Sandbox Code Playgroud)

关于如何使我的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
        }
Run Code Online (Sandbox Code Playgroud)

小智 5

对于遇到此问题的其他任何人,除了更改ping权限之外,还有另一种选择。只需将host check命令更改为即可使用check_host而不是check_ping。虽然功能肯定有所不同,但总体最终结果是相同的。

有人会说这不是一个很好的选择,因为check_ping它可以调整命令范围,但是要记住,直到对给定主机的所有服务检查都失败之后,才执行主机检查。无论如何,如果您对测试吞吐量感兴趣,那么有比依赖MUCH更好的方法ICMP,后者是网络上优先级最低的流量类型。

我确信到目前为止,OP可以很好地处理其他事情,但是希望其他遇到此问题的人能够从中受益。