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

2 用户自定义宏使用场景

2 User macros supported by location v

概述

Overview

用户自定义宏可以用于以下场景: User-definable macros are supported in the following locations:

  • 设备
    • 接口 IP/DNS
    • 接口 port
  • Hosts
    • Interface IP/DNS
    • Interface port
  • 被动 proxy
    • 接口 port
  • Items 和 item 原型
    • 名称
    • Key 参数
    • 更新间隔
    • 用户自定义间隔
    • 历史数据存储周期
    • 趋势数据存储周期
    • SNMPv3 context 名称
    • SNMPv3 security 名称
    • SNMPv3 auth 密码
    • SNMPv3 priv 密码
    • SNMPv1/v2 团体串
    • SNMP OID
    • SNMP port
    • SSH 用户名
    • SSH 公钥
    • SSH 私钥
    • SSH 密码
    • SSH 脚本
    • Telnet 用户名
    • Telnet 密码
    • Telnet 脚本
    • Calculated item 公式
    • Trapper item "Allowed hosts" 字段
    • 数据库监控附加字段
    • JMX item endpoint 字段
    • 从Zabbix 4.0开始支持以下字段:
      • item 值预处理步骤
      • HTTP agent URL 字段
      • HTTP agent HTTP query fields 字段
      • HTTP agent request body 字段
      • HTTP agent required status codes 字段
      • HTTP agent headers field key 和 value
      • HTTP agent HTTP 认证用户名字段
      • HTTP agent HTTP 认证密码字段
      • HTTP agent HTTP proxy 字段
      • HTTP agent SSL certificate 文件字段
      • HTTP agent SSL key 文件字段
      • HTTP agent SSL key 密码字段
      • HTTP agent HTTP 超时字段
      • HTTP agent HTTP 允许设备字段
  • Items and item prototypes
    • Name
    • Key parameters
    • Update interval
    • Custom intervals
    • History storage period
    • Trend storage period
    • SNMPv3 context name
    • SNMPv3 security name
    • SNMPv3 auth pass
    • SNMPv3 priv pass
    • SNMPv1/v2 community
    • SNMP OID
    • SNMP port
    • SSH username
    • SSH public key
    • SSH private key
    • SSH password
    • SSH script
    • Telnet username
    • Telnet password
    • Telnet script
    • Calculated item formula
    • Trapper item "Allowed hosts" field
    • Database monitoring additional parameters
    • JMX item endpoint field
    • since Zabbix 4.0 also in:
      • item value preprocessing steps
      • HTTP agent URL field
      • HTTP agent HTTP query fields field
      • HTTP agent request body field
      • HTTP agent required status codes field
      • HTTP agent headers field key and value
      • HTTP agent HTTP authentication username field
      • HTTP agent HTTP authentication password field
      • HTTP agent HTTP proxy field
      • HTTP agent SSL certificate file field
      • HTTP agent SSL key file field
      • HTTP agent SSL key password field
      • HTTP agent HTTP timeout field
      • HTTP agent HTTP allowed hosts field
  • 发现
    * 更新间隔
           * SNMPv3 context 字段
           * SNMPv3 security 字段
           * SNMPv3 auth 密码
           * SNMPv3 priv 密码
           * SNMPv1/v2 团体串
           * SNMP OID
       * Discovery
           * Update interval
           * SNMPv3 context name
           * SNMPv3 security name
           * SNMPv3 auth pass
           * SNMPv3 priv pass
           * SNMPv1/v2 community
           * SNMP OID
  • Low-level 发现规则
    • 名称
    • Key 参数
    • 更新间隔
    • 用户自定义间隔
    • SNMPv3 context 名称
    • SNMPv3 security 名称
    • SNMPv3 auth 密码
    • SNMPv3 priv 密码
    • SNMPv1/v2 团体串
    • SNMP OID
    • SNMP port
    • SSH 用户名
    • SSH 公钥
    • SSH 私钥
    • SSH 密码
    • SSH 脚本
    • Telnet 用户名
    • Telnet 密码
    • Telnet 脚本
    • Trapper item 允许设备字段
    • 数据库监控附加字段
    • JMX item endpoint 字段
    • 保持资源丢失时间
    • 过滤正则表达式
    • 从Zabbix 4.0开始支持以下字段:
      • HTTP agent URL 字段
      • HTTP agent HTTP query fields 字段
      • HTTP agent request body 字段
      • HTTP agent required status codes 字段
      • HTTP agent headers field key 和 value
      • HTTP agent HTTP 认证用户名字段
      • HTTP agent HTTP 认证密码字段
      • HTTP agent HTTP 超时字段
  • Low-level discovery rule
    • Name
    • Key parameters
    • Update interval
    • Custom intervals
    • SNMPv3 context name
    • SNMPv3 security name
    • SNMPv3 auth pass
    • SNMPv3 priv pass
    • SNMPv1/v2 community
    • SNMP OID
    • SNMP port
    • SSH username
    • SSH public key
    • SSH private key
    • SSH password
    • SSH script
    • Telnet username
    • Telnet password
    • Telnet script
    • Trapper item "Allowed hosts" field
    • Database monitoring additional parameters
    • JMX item endpoint field
    • Keep lost resources period
    • Filter regular expressions
    • since Zabbix 4.0 also in:
      • HTTP agent URL field
      • HTTP agent HTTP query fields field
      • HTTP agent request body field
      • HTTP agent required status codes field
      • HTTP agent headers field key and value
      • HTTP agent HTTP authentication username field
      • HTTP agent HTTP authentication password field
      • HTTP agent HTTP timeout field
  • Web scenario
    * 名称
           * 更新间隔
           * Agent
           * HTTP proxy
           * Variables
           * Headers
           * Step name
           * Step URL
           * Step post variables
           * Step headers
           * Step timeout
           * Required string
           * 必须的状态
           * 认证 (用户名和密码)
           * SSL certificate 文件
           * SSL key 文件
           * SSL key 密码
       * Web scenario 
           * Name
           * Update interval
           * Agent
           * HTTP proxy
           * Variables
           * Headers
           * Step name
           * Step URL
           * Step post variables
           * Step headers
           * Step timeout
           * Required string
           * Required status codes
           * Authentication (user and password)
           * SSL certificate file
           * SSL key file
           * SSL key password
        
       * Triggers
           * 名称
           * 表达式 (仅在常量和函数参数中)
           * 描述信息
           * URLs    
  • Triggers
    * Name
           * Expression (only in constants and function parameters)
           * Description
           * URLs
       
       
       * 基于Trigger通知
       * 基于Trigger内部通知
       * 问题更新通知
       * Trigger-based notifications
       * Trigger-based internal notifications
       * Problem update notifications
       
       * 事件tags
           * Tag 名称 
           * Tag 值 
           * Tag 匹配
       * Event tags
           * Tag name 
           * Tag value 
           * Tag for matching 
  • 动作操作
    * 默认步骤持续时间
           * 步骤持续时间
       * Action operations
           * Default operation step duration
           * Step duration
       
       * 动作条件
           * 时间周期条件
       * Action conditions
           * Time period condition
  • 全局脚本 (包括确认文本)
  • Global scripts (including confirmation text)
  • dynamic URL screen 元素的URL字段。
  • URL field of dynamic URL screen element
  • 管理 → 用户 → 媒介: 'When active' 字段。
  • 管理 → 一般 → 工作时间: 'Working time' 字段。
  • Administration → Users → Media: 'When active' field
  • Administration → General → Working time: 'Working time' field

需要Zabbix所支持宏的完整列表, 请参考 支持宏列表。 For a complete list of all macros supported Zabbix, see macros supported by location.

Items / item prototypes

In an item or an item prototype configuration, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Name (deprecated) yes
Item key parameters yes
Update interval no
Custom intervals no
History storage period no
Trend storage period no
//Calculated item //
Formula yes
Database monitor
Username yes
Password yes
SQL query yes
//HTTP agent //
URL yes
Query fields yes
Timeout no
Request body yes
Headers (names and values) yes
Required status codes yes
HTTP proxy yes
HTTP authentication username yes
HTTP authentication password yes
SSl certificate file yes
SSl key file yes
SSl key password yes
Allowed hosts yes
JMX agent
JMX endpoint yes
//SNMP agent //
SNMP OID yes
//SSH agent //
Username yes
Public key file yes
Private key file yes
Password yes
Script yes
//TELNET agent //
Username yes
Password yes
Script yes
//Zabbix trapper //
Allowed hosts yes
Preprocessing
Step parameters yes

Low-level discovery

In a low-level discovery rule, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Name yes
Key parameters yes
Update interval no
Custom interval no
Keep lost resources period no
SNMP agent
SNMP OID yes
SSH agent
Username yes
Public key file yes
Private key file yes
Password yes
Script yes
TELNET agent
Username yes
Password yes
Script yes
Zabbix trapper
Allowed hosts yes
Database monitor
Additional parameters yes
JMX agent
JMX endpoint yes
HTTP agent
URL yes
Query fields yes
Timeout no
Request body yes
Headers (names and values) yes
Required status codes yes
HTTP authentication username yes
HTTP authentication password yes
//Filters //
Regular expression yes

Network discovery

In a network discovery rule, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Update interval no
SNMP v1, v2
SNMP community yes
SNMP OID yes
SNMP v3
Context name yes
Security name yes
Authentication passphrase yes
Privacy passphrase yes
SNMP OID yes

Proxies

In a proxy configuration, user macros can be used in the following field:

Location Multiple macros/mix with text1
Interface port (for passive proxy) no

Templates

In a template configuration, user macros can be used in the following fields:

Location Multiple macros/mix with text1
//Tags //
Tag names yes
Tag values yes

Triggers

In a trigger configuration, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Name yes
Operational data yes
Expression (only in constants and function parameters; secret macros are not supported). yes
Description yes
URL yes
Tag for matching yes
//Tags //
Tag names yes
Tag values yes

Web scenario

In a web scenario configuration, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Name yes
Update interval no
Agent yes
HTTP proxy yes
Variables (values only) yes
Headers (names and values) yes
//Steps //
Name yes
URL yes
Variables (values only) yes
Headers (names and values) yes
Timeout no
Required string yes
Required status codes no
//Authentication //
User yes
Password yes
SSL certificate yes
SSL key file yes
SSL key password yes

Other locations

In addition to the locations listed here, user macros can be used in the following fields:

Location Multiple macros/mix with text1
Global scripts (including confirmation text) yes
Monitoring → Screens
URL field of dynamic URL screen element yes
Administration → Users → Media
When active no
Administration → General → Working time
Working time no

For a complete list of all macros supported in Zabbix, see supported macros.

Footnotes

1 If multiple macros in a field or macros mixed with text are not supported for the location, a single macro has to fill the whole field.