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
  • 发现

  1. * 更新间隔
  2. * SNMPv3 context 字段
  3. * SNMPv3 security 字段
  4. * SNMPv3 auth 密码
  5. * SNMPv3 priv 密码
  6. * SNMPv1/v2 团体串
  7. * SNMP OID
  8. * Discovery
  9. * Update interval
  10. * SNMPv3 context name
  11. * SNMPv3 security name
  12. * SNMPv3 auth pass
  13. * SNMPv3 priv pass
  14. * SNMPv1/v2 community
  15. * 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

  1. * 名称
  2. * 更新间隔
  3. * Agent
  4. * HTTP proxy
  5. * Variables
  6. * Headers
  7. * Step name
  8. * Step URL
  9. * Step post variables
  10. * Step headers
  11. * Step timeout
  12. * Required string
  13. * 必须的状态
  14. * 认证 (用户名和密码)
  15. * SSL certificate 文件
  16. * SSL key 文件
  17. * SSL key 密码
  18. * Web scenario
  19. * Name
  20. * Update interval
  21. * Agent
  22. * HTTP proxy
  23. * Variables
  24. * Headers
  25. * Step name
  26. * Step URL
  27. * Step post variables
  28. * Step headers
  29. * Step timeout
  30. * Required string
  31. * Required status codes
  32. * Authentication (user and password)
  33. * SSL certificate file
  34. * SSL key file
  35. * SSL key password
  36. * Triggers
  37. * 名称
  38. * 表达式 (仅在常量和函数参数中)
  39. * 描述信息
  40. * URLs
  • Triggers
  1. * Name
  2. * Expression (only in constants and function parameters)
  3. * Description
  4. * URLs
  5. * 基于Trigger通知
  6. * 基于Trigger内部通知
  7. * 问题更新通知
  8. * Trigger-based notifications
  9. * Trigger-based internal notifications
  10. * Problem update notifications
  11. * 事件tags
  12. * Tag 名称
  13. * Tag
  14. * Tag 匹配
  15. * Event tags
  16. * Tag name
  17. * Tag value
  18. * Tag for matching
  • 动作操作
  1. * 默认步骤持续时间
  2. * 步骤持续时间
  3. * Action operations
  4. * Default operation step duration
  5. * Step duration
  6. * 动作条件
  7. * 时间周期条件
  8. * Action conditions
  9. * 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:

LocationMultiple macros/mix with text1
Name (deprecated)yes
Item key parametersyes
Update intervalno
Custom intervalsno
History storage periodno
Trend storage periodno
Descriptionyes
Calculated item
Formulayes
Database monitor
Usernameyes
Passwordyes
SQL queryyes
//HTTP agent //
URL2yes
Query fieldsyes
Timeoutno
Request bodyyes
Headers (names and values)yes
Required status codesyes
HTTP proxyyes
HTTP authentication usernameyes
HTTP authentication passwordyes
SSl certificate fileyes
SSl key fileyes
SSl key passwordyes
Allowed hostsyes
JMX agent
JMX endpointyes
Script item
Parameter names and valuesyes
SNMP agent
SNMP OIDyes
SSH agent
Usernameyes
Public key fileyes
Private key fileyes
Passwordyes
Scriptyes
TELNET agent
Usernameyes
Passwordyes
Scriptyes
Zabbix trapper
Allowed hostsyes
Tags
Tag namesyes
Tag valuesyes
Preprocessing
Step parameters (including custom scripts)yes

Low-level discovery

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

LocationMultiple macros/mix with text1
Nameyes
Key parametersyes
Update intervalno
Custom intervalno
Keep lost resources periodno
Descriptionyes
SNMP agent
SNMP OIDyes
SSH agent
Usernameyes
Public key fileyes
Private key fileyes
Passwordyes
Scriptyes
TELNET agent
Usernameyes
Passwordyes
Scriptyes
Zabbix trapper
Allowed hostsyes
Database monitor
Additional parametersyes
JMX agent
JMX endpointyes
HTTP agent
URL2yes
Query fieldsyes
Timeoutno
Request bodyyes
Headers (names and values)yes
Required status codesyes
HTTP authentication usernameyes
HTTP authentication passwordyes
Filters
Regular expressionyes
Overrides
Filters: regular expressionyes
Operations: update interval (for item prototypes)no
Operations: history storage period (for item prototypes)no
Operations: trend storage period (for item prototypes)no

Network discovery

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

LocationMultiple macros/mix with text1
Update intervalno
SNMP v1, v2
SNMP communityyes
SNMP OIDyes
SNMP v3
Context nameyes
Security nameyes
Authentication passphraseyes
Privacy passphraseyes
SNMP OIDyes

Proxies

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

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

Templates

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

LocationMultiple macros/mix with text1
//Tags //
Tag namesyes
Tag valuesyes

Triggers

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

LocationMultiple macros/mix with text1
Nameyes
Operational datayes
Expression (only in constants and function parameters; secret macros are not supported).yes
Descriptionyes
URL2yes
Tag for matchingyes
Tags
Tag namesyes
Tag valuesyes

Web scenario

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

LocationMultiple macros/mix with text1
Nameyes
Update intervalno
Agentyes
HTTP proxyyes
Variables (values only)yes
Headers (names and values)yes
Steps
Nameyes
URL2yes
Variables (values only)yes
Headers (names and values)yes
Timeoutno
Required stringyes
Required status codesno
Authentication
Useryes
Passwordyes
SSL certificateyes
SSL key fileyes
SSL key passwordyes
Tags
Tag namesyes
Tag valuesyes

Other locations

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

LocationMultiple macros/mix with text1
Global scripts (script, SSH, Telnet, IPMI), including confirmation textyes
Webhooks
JavaScript scriptno
JavaScript script parameter nameno
JavaScript script parameter valueyes
Monitoring → Dashboards
URL2 field of dynamic URL dashboard widgetyes
Administration → Users → Media
When activeno
Administration → General → GUI
Working timeno
Administration → Media types → Message templates
Subjectyes
Messageyes

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.

2 URLs that contain a secret macro will not work, as the macro in them will be resolved as “******“.