Introduction to Macros (macro) on Zabbix

Source: Internet
Author: User

Macros: macro, preset text substitution mode:

A macro is an abstract concept (abstraction) that replaces certain text patterns based on some of the predefined rules of a column, whereas an explanation or compiler automatically replaces this pattern when it encounters a macro. Similarly, Zabbix saves the preset text pattern based on a macro, and replaces it with the text in it when it is called.


The built-in {MACRO} does not need to be added $ to reference:

Zabbix has many built-in macros, such as {host.name}, {HOST. IP}, {TRIGGER. DESCRIPTION}, {trigger.name}, {TRIGGER. EVENTS. ACK}, and so on.

For system built-in macros, refer to Zabbix official documentation:

Https://www.zabbix.com/documentation/3.0/manual/appendix/macros/supported_by_location

1 Macros supported by Location section


The custom {$MACRO} needs to be added $ to reference:

Note: You need to add $ for both calls and definitions

For greater flexibility, Zabbix also supports the use of user-defined macros at the Global, template, or host level

User-defined macros use the special syntax format "{$MACRO}"

Macros can be applied in the item keys and descriptions, trigger names and expressions, host interfaces Ip/dns and ports, and the discovery mechanism for information about the SNMP protocol medium.

The name of the macro can only use uppercase letters, numbers, and underscores

User-defined macros are available in the following two ways:

Global macro: "Administrator-->general-->macros"

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M00/95/33/wKioL1kSwbLhSLr0AAK9rhk06MM763.jpg "title=" 1.jpg "alt=" Wkiol1kswblhslr0aak9rhk06mm763.jpg "/>

Host or template-level macros: Edit the properties of the appropriate host or template to

For user-defined macros, refer to the Zabbix official documentation:

Https://www.zabbix.com/documentation/3.0/manual/appendix/macros/supported_by_location

Additional Support for User macros section


The level of the macro:

Global: Define global macros, globally defined

Templates: Defining template macros, defining them on a template

Host: Define a host macro, defined on the host


Substitution Order for macros:

The host uses the macro:

Hosts--Templates--Global (lookup order, priority order: host------)

Look on the host first, if the host is not defined, and then look in the template, if still not defined, in the global find

The first is the host-level macros;

Second, the current host in the first-level template (directly linked to the host template) of the macro, a number of first-class templates by their ID number sorting;

In the following is the macro in Level two template (template linked template);

The last check is the global macro;

Zabbix If you cannot find a macro that is used by a host definition, it will not be replaced.


Macros Use Example:

Define a macro named {$CPUMAXSWITCHES} at the host level to define a reasonable number of CPU context switches accepted by the current host

650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M01/95/33/wKioL1kSwRSS2IRfAANffN1lE6Y308.jpg "style=" float : none; "title=" 1.jpg "alt=" Wkiol1kswrss2irfaanffn1le6y308.jpg "/>

Use this macro variable in trigger:

650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M02/95/34/wKiom1kSwRXDtKLSAANLLFMhxS4134.jpg "style=" float : none; "title=" 2.jpg "alt=" Wkiom1kswrxdtklsaanllfmhxs4134.jpg "/>


This article is from the "Wang Liming" blog, make sure to keep this source http://afterdawn.blog.51cto.com/7503144/1924147

Introduction to Macros (macro) on Zabbix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.