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

3 自动发现(LLD)宏




它是一个在LLD规则中使用的宏,并返回文件系统名称、网络接口和 SNMP OIDs。




LLD 宏可以用在:

  • 用于监控项原型中:
    • names
    • key parameters
    • units
    • SNMP OIDs
    • IPMI sensor fields
    • calculated item formulas
    • SSH and Telnet scripts
    • database monitoring SQL queries
    • descriptions (从 2.2.0 开始支持)
  • 用于触发器原型中:
    • names
    • expressions
    • URLs (从 3.0.0 开始支持)
    • descriptions (从 2.2.0 开始支持)
    • event tag names and values (从 3.2.0 开始支持)
  • 用于图形原型中:
    • names
  • 用于主机原型中 (从 2.2.0 开始支持):
    • names
    • visible names
    • host group prototype names
    • (详细查阅 全部列表)

在上述所有位置,LLD 宏都可以在用户宏上下文中使用。

一些自动发现(LLD)宏在 Zabbix 中是已经预先内置的,例如 {#FSNAME}、 {#FSTYPE}、{#IFNAME}、 {#SNMPINDEX}、 {#SNMPVALUE} 这些宏。然而,当你在创建自定义自动发现规则的时候,遵守这些宏名称不是强制性的。所以,你可以使用任何其他的 LLD 宏名称并引用该名称。

Using macro functions

Macro functions are supported with low-level discovery macros (except in low-level discovery rule filter), allowing to extract a certain part of the macro value using a regular expression.

For example, you may want to extract the customer name and interface number from the following LLD macro for the purposes of event tagging:


To do so, the regsub macro function can be used with the macro in the event tag value field of a trigger prototype:

Note, that commas are not allowed in unquoted item key parameters, so the parameter containing a macro function has to be quoted. The backslash (\) character should be used to escape double quotes inside the parameter. Example:

net.if.in["{{#IFALIAS}.regsub(\"(.*)_([0-9]+)\", \1)}",bytes]

For more information on macro function syntax, see: Macro functions

Macro functions are supported in low-level discovery macros since Zabbix 4.0.


1 In the fields marked with 1 a single macro has to fill the whole field. Multiple macros in a field or macros mixed with text are not supported.