Skip to content

Zabbix macros and variables

Zabbix macros are text variables used within the Zabbix monitoring system to dynamically substitute values, making configurations and templates more flexible and reusable^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md].

A common syntax for these variables involves enclosing the macro name in curly braces prefixed by a dollar sign, such as {$MACRO_NAME}^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md]. This format is often referred to as a user-defined macro.

Usage in configuration

In the Zabbix agent configuration file (zabbix_agentd.conf), macros are frequently employed to define parameter values^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md]. A standard use case is defining the Server parameter, which specifies the IP addresses or DNS names of Zabbix servers or Zabbix proxies that are allowed to connect to the agent^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md].

For example, a configuration line might define multiple server addresses:

Server=zabbix.mypay1.com,10.140.0.23
While the configuration uses plain text in this instance, utilizing macros allows these values to be abstracted into variables.

Examples of macros

Specific macros often begin with a dollar sign and curly braces, like {$CONTEXT}^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md]. Other variations may include more descriptive names to indicate their function, such as {$HOST_DOMAIN_NAME}^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md].

Sources

^[600-developer-operation-maintenance-zabbix-zabbix-agentd.md]