【问题标题】:How to disable host checks of existing hosts in Nagios?如何禁用 Nagios 中现有主机的主机检查?
【发布时间】:2020-10-10 15:10:16
【问题描述】:

我有两台主机,它们的主机检查不再起作用(因为 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 实际运行的是什么命令)并且主机保持状态 DOWN

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

我希望 Nagios 停止对这些主机进行主机检查,并将状态返回到 OK/UP。实现这一目标的正确方法是什么?

【问题讨论】:

    标签: nagios


    【解决方案1】:

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

    1. 您可以从 Nagios Web UI 中禁用通知。您只需要找到该主机并继续使用Disable notifications for this host。 Nagios 仍将检查此主机,但不再生成通知。解决防火墙问题后,必须手动启用通知。
    2. 您可以Acknowledge this host problem 在与禁用通知(Web UI)相同的位置。这使您可以禁用通知并对此问题进行一些评论/注释。当主持人将其状态更改为 UP(绿色)时,通知会自动启用。
    3. 您甚至可以从 Web UI 禁用主机检查。将Disable active checks of this host 选项与Disable notifications for this host 一起使用。这会禁用通知,并且 Nagios 也会停止 ping 远程主机。但不要忘记在修复防火墙问题/规则后启用这些选项。

    【讨论】:

    • 谢谢!但是我的主要问题是,对于任何这些解决方案,Nagios 都会将主机显示为DOWN。我该如何改变呢?
    • 好的,Nagios 服务器允许 SSH 吗?如果是,那么您可以将检查更改为 check_tcp 到端口 22 而不是 check_ping
    • 不,不是。我可以对另一个端口做类似的事情,但这会破坏检查的重点。我已经检查了各个服务,但我希望能够 dist.看起来我想要的 Nagios 根本不可能,所以我将禁用通知或类似的东西。感谢您的帮助!
    • 也许 Nagios 插件 check_dummy 是你要找的。它是nagios-plugins-dummy 包的一部分。您可以在定义中的主机中设置它check_command check_dummy!0!Always OK
    【解决方案2】:

    您可以使用 check_dummy check 命令强制主机检查始终返回 OK。

    例如,将以下命令定义放在您的 commands.cfg 文件中:

    # 'check_dummy' command definition
    # NOTE: This command always returns an 'OK' result no matter what.
    define command{
            command_name    check_dummy
            command_line    $USER1$/check_dummy 0
    }
    

    然后在您的主机定义中添加以下行:

    check_command   check_dummy
    

    重新启动 nagios 服务,您的不可 ping 主机现在将始终处于“UP”状态。

    【讨论】:

      【解决方案3】:

      您是否尝试过清除retention.dat? 这将清除所有当前主机和服务状态、所有 cmets、停机时间等。 基本上从一个干净的状态开始。

      > cd /usr/local/nagios/var
      > (optional) cp retention.dat retention.dat.backup
      > rm retention.dat
      > service nagios restart
      

      编辑:这应该与此处的其他解决方案一起使用。首先禁用主机检查,然后通过清除保留数据进行重置。 这可能会或可能不会获得您想要的主机状态,但它们将不再是 DOWN 或抛出通知

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多