[comment]: # ({53002c76-bf190b3f})
# 12 不可达/不可用 主机设置

[comment]: # ({/53002c76-bf190b3f})

[comment]: # ({94d84fca-3c58c381})
#### 概述

当agent检查(Zabbix, SNMP, IPMI, JMX)失败并且主机变得不可达时，一些配置
[参数](/manual/appendix/config/zabbix_server) 定义了 Zabbix server
作何反应。

[comment]: # ({/94d84fca-3c58c381})

[comment]: # ({cc69c3e9-7abc1669})
#### 不可达主机

Zabbix, SNMP, IPMI 或 JMX
agents检查（网络错误，超时）失败后即视主机不可达. 注意，Zabbix agent
主动检查不影响主机可用性。

From that moment **UnreachableDelay**定义了主机再次检查的频率 is
rechecked using one of the items (包括 LLD 规则) in this unreachability
situation and such rechecks will be performed already by unreachable
pollers.默认情况下，两次检查时间间隔为15秒。

在Zabbix server 日志中 ，不可达是通过类似下面的消息表示的:

    Zabbix agent item "system.cpu.load[percpu,avg1]" on host "New host" failed: first network error, wait for 15 seconds
    Zabbix agent item "system.cpu.load[percpu,avg15]" on host "New host" failed: another network error, wait for 15 seconds

注意，失败的监控项和监控项类型（Zabbix agent）列出来了。

::: noteclassic
在主机不可达期间，*Timeout*
参数也会影响主机再次被检查的时间。如果Timeout 是 20 秒，但是
UnreachableDelay 是 30 秒, 下一次检查在 50 秒后 。
:::

**UnreachablePeriod**参数定义了不可达的总时长。 UnreachablePeriod 应该比
UnreachableDelay大几倍, 这样在主机变为不可用之前，主机会被检查不止一次。

如果不可达主机再次出现, 监控自动恢复正常:

恢复 Zabbix agent 对主机 "New host"的检查: 连接恢复

[comment]: # ({/cc69c3e9-7abc1669})

[comment]: # ({2df10cda-699a1f43})
#### 不可用主机

主机不可达期结束后主机没有再次出现, 视主机为不可用。

在server 日志中，不可用是通过类似下面的消息来表示的:

    temporarily disabling Zabbix agent checks on host "New host": host unavailable

在[前端](/manual/web_interface/frontend_sections/configuration/hosts)
主机可用性图标由绿色（或灰色）变为红色（注意，在鼠标经过时会提示错误描述）:

![](../../../../assets/zh/manual/config/unavailable.png)

**UnavailableDelay** 参数定义了在主机不可用期间，主机被检查的频率。

默认为 60 秒 (所以此时从上面的日志信息来看， "temporarily
disabling"意味着禁用检查一分钟)。

当主机连接恢复时，监控也会自动恢复正常:

    启用Zabbix agent 对 "New host"主机的检查: 主机变为可达

[comment]: # ({/2df10cda-699a1f43})

[comment]: # ({e7fe9e10-e7fe9e10})
#### Unavailable host

After the UnreachablePeriod ends and the host has not reappeared, the
host is treated as unavailable.

In the server log it is indicated by messages like these:

    temporarily disabling Zabbix agent checks on host "New host": host unavailable

and in the
[frontend](/manual/web_interface/frontend_sections/configuration/hosts)
the host availability icon for the respective interface goes from green
(or gray) to red (note that on mouseover a tooltip with the error
description is displayed):

![](../../../../assets/en/manual/config/unavailable.png)

The **UnavailableDelay** parameter defines how often a host is checked
during host unavailability.

By default it is 60 seconds (so in this case "temporarily disabling",
from the log message above, will mean disabling checks for one minute).

When the connection to the host is restored, the monitoring returns to
normal automatically, too:

    enabling Zabbix agent checks on host "New host": host became available

[comment]: # ({/e7fe9e10-e7fe9e10})
