Skip to content

Macro (Host)

define_host_macro

define_host_macro <HOSTNAME> <MACRO_NAME> <MACRO_VALUE>

Define a host macro.

Examples

Create a macro named {$SNMP_COMMUNITY} for a host

define_host_macro foo.example.com '{$SNMP_COMMUNITY}' public

Create a macro named {$SITE_URL} for a host (automatic name conversion)

define_host_macro foo.example.com site_url https://example.com

Arguments

HOSTNAME
Host to define macro for.
Type: text
Required:

MACRO_NAME
Name of macro. Names will be converted to the Zabbix format, i.e. site_url becomes {$SITE_URL}.
Type: text
Required:

MACRO_VALUE
Default value of macro.
Type: text
Required:


define_template_macro

define_template_macro <TEMPLATE_NAME> <MACRO_NAME> <MACRO_VALUE>

Define a template macro.

Examples

Create a macro named {$SNMP_COMMUNITY} with the value 'public' for a template

define_template_macro Mytemplate '{$SNMP_COMMUNITY}' public

Create a macro named {$SITE_URL} with an URL value for a template (automatic name conversion)

define_template_macro Mytemplate site_url https://example.com

Arguments

TEMPLATE_NAME
Name of template to define macro for.
Type: text
Required:

MACRO_NAME
Name of macro. Names will be converted to the Zabbix format, i.e. site_url becomes {$SITE_URL}.
Type: text
Required:

MACRO_VALUE
Default value of macro.
Type: text
Required:


show_host_macros

show_host_macros <HOSTNAME_OR_ID>

Show all macros defined for a host.

Arguments

HOSTNAME_OR_ID
Hostname or ID to show macros for
Type: text
Required:


show_macro_hosts

show_macro_hosts <USERMACRO> [OPTIONS]

Find all hosts with a user macro of the given name.

Renders a list of the complete macro object and its hosts in JSON mode.

Arguments

USERMACRO
Name of macro to find hosts with. Macro names are automatically formatted, e.g. site_url becomes {$SITE_URL}.
Type: text
Required:

Options

--limit, -n <LIMIT>
Limit the number of results. 0 to show all.
Type: integer
Default: 0


show_macro_templates

show_macro_templates <MACRO_NAME> [OPTIONS]

Find all templates with a macro of the given name.

Examples

Show all templates with a user macro named {$SNMP_COMMUNITY}

show_macro_templates SNMP_COMMUNITY

Arguments

MACRO_NAME
Name of the macro to find templates with. Automatically formatted.
Type: text
Required:

Options

--limit, -n <LIMIT>
Limit the number of results. 0 to show all.
Type: integer
Default: 0


show_template_macros

show_template_macros <TEMPLATE_NAME_OR_ID>

Show all macros defined for a template.

Arguments

TEMPLATE_NAME_OR_ID
Template name or ID to show macros for
Type: text
Required: