2022 Zabbix中国峰会
2022 Zabbix中国峰会

2 链接/取消链接

概述

Linking is a process whereby templates are applied to hosts, whereas unlinking removes the association with the template from a host.

链接是将模板应用于主机的过程,而取消链接将从主机中删除与模板的关联。

<note important>模板直接链接到各个主机,而不是主机组。只需将模板添加到主机组就不会链接到主机组。主机组仅用于主机和模板的逻辑分组。 :::

链接模板

要将模板链接到主机,请执行以下操作:

  • 转到配置→主机
  • 单击所需的主机并切换到模板选项卡
  • 点击链接指示器旁边的选择
  • 在弹出窗口中选择一个或多个模板
  • 单击主机属性窗体中的添加/更新

The host will now have all the entities (items, triggers, graphs, etc) of the template.

主机现在将拥有模板的所有实体(项目,触发器,图形等)。

<note important>如果在那些模板中有相同监控项的项,如链接到相同的主机将失败。并且作为触发器和图形使用项目,如果使用相同的项目键,它们也不能从多个模板链接到单个主机。 :::

当从模板添加实体(监控项,触发器,图表等)时:

  • 主机上以前存在的相同实体被更新为模板的实体
  • 添加模板中的实体
  • any directly linked entities that, prior to template linkage, existed only on the host remain untouched
  • 在模板连接之前,只存在于主机上的任何直接链接的实体保持不变

In the lists, all entities from the template now are prefixed by the template name, indicating that these belong to the particular template. The template name itself (in grey text) is a link allowing to access the list of those entities on the template level.

在列表中,模板中的所有实体都以模板名称为前缀,表示这些属于特定模板。模板名称本身(灰色文本)是允许访问模板级别上这些实体列表的链接。

If some entity (item, trigger, graph etc.) is not prefixed by the template name, it means that it existed on the host before and was not added by the template.

如果某个实体(监控项,触发器,图表等)未被模板名称前缀,则表示该模板存在于主机之前,并未被模板添加。

实体唯一性标准

When adding entities (items, triggers, graphs etc.) from a template it is important to know what of those entities already exist on the host and need to be updated and what entities differ. The uniqueness criteria for deciding upon the sameness/difference are:

从模板中添加实体(监控项,触发器,图表等)时,重要的是要知道这些实体已经存在于主机上并需要更新,哪些实体有所不同。决定同一性/差异的唯一性标准是:

  • for items - the item key
  • 用于监控项 - 项目键
  • for triggers - trigger name and expression
  • 用于触发器 - 触发器名称和表达式
  • for custom graphs - graph name and its items
  • 用于自定义图形 - 图形名称及其项目
  • for applications - application name
  • 用于应用集 - 应用集名称
将模板链接到多个主机

There are some ways of mass-applying templates (to many hosts at once): 有一些批量应用模板的方法(对许多主机一次搞定):

  • To link a template to many hosts, in Configuration → Templates, click on the template, then select hosts from the respective group in the Other box, click on << and update the template.
  • 要将模板链接到许多主机,请在配置→模板中单击模板,然后从其他主机框中的相应组中选择主机,然后单击 <<更新模板。

Vice versa, if you select the linked hosts in the In box, click on >> and update the template, you unlink the template from these hosts (while the hosts will still inherit the items, triggers, graphs etc. from the template).

反之亦然,如果您在“收件箱”中选择链接的主机,请单击 >>并更新模板,从该模板中取消链接模板(主机仍将从模板继承监控项,触发器,图表等)。

  • To update template linkage of many hosts, in Configuration → Hosts select some hosts by marking their checkboxes, then click on Mass update below the list and then in the Templates tab select to link additional templates:
  • 要更新许多主机的模板链接,在配置→主机中通过标记其复选框来选择一些主机,然后单击列表下方的批量更新,然后在模板选项卡中选择链接其他模板:

Select Link templates and start typing the template name in the auto-complete field until a dropdown appears offering the matching templates. Just scroll down to select the template to link.

选择链接模板,并在自动完成字段中开始输入模板名称,直到出现一个提供匹配模板的下拉列表。只需向下滚动即可选择要链接的模板。

The Replace option will allow to link a new template while unlinking any template that was linked to the hosts before. The Clear when unlinking option will allow to not only unlink any previously linked templates, but also remove all elements inherited from them (items, triggers, etc.).

替换选项将允许同时取消关联之前被连接到主机的任何模板链接一个新的模板。在取消链接并清理选项将允许不仅取消链接任何以前链接的模板,但也从中移除(监控项,触发器等)继承了所有元素。

<note tip>Zabbix提供了大量预定义的模板。您可以使用这些作为参考,但请注意在生产中不改变使用它们,因为它们可能包含太多监控项,并且太频繁地轮询数据。如果你喜欢它们,确保它们以适和你的需求。 :::

编辑链接实体

If you try to edit an item or trigger that was linked from the template, you may realize that many key options are disabled for editing. This makes sense as the idea of templates is that things are edited in one-touch manner on the template level. However, you still can, for example, enable/disable an item on the individual host and set the update interval, history length and some other parameters.

如果你尝试编辑从模板链接的监控项或触发器,你可能会意识到许多关键选项被禁用以进行编辑。这是有道理的,因为模板的想法是在模板级别上以一触式方式编辑事物。但是,你仍然可以启用/禁用单个主机上的监控项,并设置更新间隔,历史长度和其他一些参数。

If you want to edit the entity fully, you have to edit it on the template level (template level shortcut is displayed in the form name), keeping in mind that these changes will affect all hosts that have this template linked to them.

如果要完全编辑实体,则必须在模板级别进行编辑(模板级快捷方式以表单名称显示),请注意,这些更改将影响所有与此模板链接的主机。

取消链接模板

要从主机中取消链接模板,请执行以下操作:

  • 转到配置→主机
  • Click on the required host and switch to the Templates tab
  • 单击所需的主机并切换到模板选项卡
  • 单击取消链接取消链接并清理模板旁边以取消链接
  • 单击主机属性窗体中的更新

Choosing the Unlink option will simply remove association with the template, while leaving all its entities (items, triggers, graphs etc.) with the host.

选择取消链接选项将简单地删除与模板的关联,同时将其所有实体(监控项,触发器,图形等)与主机保持一致。

Choosing the Unlink and clear option will remove both the association with the template and all its entities (items, triggers, graphs etc.).

选择取消链接并清理选项将删除与模板及其所有实体(监控项,触发器,图表等)的关联。