更改 Nagios 判断服务器是否离线的方式?

更改 Nagios 判断服务器是否离线的方式?

我是 nagios 新手,我的服务器所在的网络不允许对服务器进行 ping 操作。我可以通过其他方式检查服务器是否正常运行吗?例如通过 SSH 或 HTTP?我该如何操作才能在 nagios 报告中不显示服务器处于离线状态(其实服务器处于在线状态)?

答案1

在您的主机定义中,您可以指定您想要使用的命令。

define host{
        use                                     generic-host
        host_name                               SVR_1
        alias                                   SVR_1
        address                                 10.0.0.6
        check_command                   check-host-alive
        max_check_attempts              2
        notification_interval   120
        notification_period             24x7
        notification_options    d,u,r
        }

因此,通常在 checkcommands.cfg 中您会根据需要创建一个新命令,或者您也可以只使用 check_http。

define command{
        command_name    check-host-alive
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1
        }

答案2

你可能在 hosts.cfg 中将服务器配置为主机,其中有一行类似

check_command           check-host-alive

check-host-alive 在 command.cfg 中定义以使用 check_ping。

我建议您将 check_command 更改为类似 my-check-host-alive 的内容,并在 command.cfg 中定义 my-check-host-alive 以使用类似 check_tcp 的内容。

使用 -h 启动 check_tcp 来查看它的帮助。

答案3

使用不同的设备状态检查,默认情况下使用主机活动检查,使用 check_nrpe 检查或无论您如何测试它。

检查 Centreon,应该可以简化您的 nagios 配置。

答案4

感谢您的反馈。使用 check_http 帮助我删除了我正在监控的远程网站,因为我无法 ping 到它。

很好的讨论。这也适用于 icinga。实际上我正在使用 icinga,大多数通用主机文件如下,以便清晰地监控网站。

###################### define host{ name remote-site-host ; 此主机模板的名称 Notifications_enabled 1 ; 主机通知已启用 event_handler_enabled 1 ; 主机事件处理程序已启用 flap_detection_enabled 1 ; 已启用抖动检测 Failure_prediction_enabled 1 ; 已启用故障预测 process_perf_data 1 ; 进程性能数据 retain_status_information 1 ; 在程序重启时保留状态信息 retain_nonstatus_information 1 ; 在程序重启时保留非状态信息 check_command check_http max_check_attempts 3 notification_interval 0 notification_period 24x7 notification_options d,u,r register 0 ; 请勿注册此定义 - 它不是真正的主机,只是一个模板! } #########

相关内容