2022 Zabbix中国峰会
2022 Zabbix中国峰会
Table of Contents

10 宏

10 Macros




Zabbix supports a number of macros which may be used in various situations. Macros are variables, identified by a specific syntax:


根据在上下文中, 宏解析为一个特殊的值。

Macros resolve to a specific value depending on the context.


Effective use of macros allows to save time and make Zabbix configuration more transparent.

在一个的典型用途中,宏可以用于模板中。因此,模板的触发器可能命名为“Processor load is too high on {HOST.NAME}”。当这个模板应用与主机(如 Zabbix Server )时,并且当触发器展示在监控页面上时,触发器的名称讲解析为“Processor load is too high on Zabbix server”。

In one of typical uses, a macro may be used in a template. Thus a trigger on a template may be named "Processor load is too high on {HOST.NAME}". When the template is applied to the host, such as Zabbix server, the name will resolve to "Processor load is too high on Zabbix server" when the trigger is displayed in the Monitoring section.

宏可以在监控项键值参数中使用。宏只能用在监控项键值参数的一部分中,例如 item.key[server_{HOST.HOST}_local] 。双引号参数不是必须的,因为Zabbix将处理任何模糊不清的特殊参数(如果这些参数存在于已解析的宏中)。

Macros may be used in item key parameters. A macro may be used for only a part of the parameter, for example item.key[server_{HOST.HOST}_local]. Double-quoting the parameter is not necessary as Zabbix will take care of any ambiguous special symbols, if present in the resolved macro.


See also: