如何禁用Nagios中现有主机的主机检查?

问题描述

我有两个主机,这些主机的主机检查不再起作用(因为ping被防火墙阻止了),导致Nagios发送有关它们的通知,并将它们列出为DOWN显示为红色。我想暂时禁用这些主机的主机检查(但不删除它们,或禁用对它们上的服务的检查,因为它们可以正常工作)。最好的方法是什么?

我尝试将其定义更改为use generic-host,而不是use linux-server。这些模板的定义如下:

define host{
        name                            linux-server    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
        check_period                    24x7            ; By default,Linux hosts are checked round the clock
        check_interval                  5               ; Actively check the host every 5 minutes
        retry_interval                  1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts              10              ; Check each Linux host 10 times (max)
        check_command                   check-host-alive ; Default command to check Linux hosts
        notification_period             workhours       ; Linux admins hate to be woken up,so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
                                                        ; the value that is inherited from the generic-host template!
        notification_interval           120             ; Resend notifications every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
        contact_groups                  admins          ; Notifications get sent to the admins by default
        register                        0               ; DONT REGISTER THIS DEFinitioN - ITS NOT A REAL HOST,JUST A TEMPLATE!
        }

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1               ; Host notifications are enabled
        event_handler_enabled           1               ; Host event handler is enabled
        flap_detection_enabled          1               ; Flap detection 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                        0               ; DONT REGISTER THIS DEFinitioN - ITS NOT A REAL HOST,JUST A TEMPLATE!
        max_check_attempts              1
        }

我曾期望主机检查能够停止,因为generic-host没有配置check_command,但是它们继续执行(不知道Nagios实际在运行什么命令)并且主机保持状态{{1 }}。

我还尝试过在主机的定义中添加一条空的DOWN行,以覆盖check_command参数为空白,Nagios的文档说该参数应禁用主机检查,但随后Nagios不接受配置,说“没有名为”的命令。”

我想要的是让Nagios停止对这些主机进行主机检查,并使状态返回到check_command / OK。实现该目标的正确方法是什么?

解决方法

您有几个选择,甚至不需要编辑配置文件。

  1. 您可以从Nagios网络用户界面禁用通知。您所需要做的就是找到该主机,然后继续Disable notifications for this host。 Nagios仍将检查此主机,但不再生成通知。解决防火墙问题后,必须手动启用通知。
  2. 您可以在Acknowledge this host problem上与禁用通知的位置相同(Web UI)。这使您可以禁用通知,还可以对此问题添加一些注释/注释。当主机将其状态更改为“启动”(绿色)时,会自动自动启用通知。
  3. 您甚至可以从Web UI禁用主机检查。将Disable active checks of this hostDisable notifications for this host一起使用。此禁用通知,并且Nagios也停止对远程主机执行ping操作。但是,修复防火墙问题/规则后,请不要忘记启用这些选项。

Nagios options for host in web UI