Ad Widget

Collapse

How to concatenate template level macros with host level macros on a host level

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kapslok
    Junior Member
    • Jun 2025
    • 2

    #1

    How to concatenate template level macros with host level macros on a host level

    Hi All.
    Appreciate if you might advise on the following question:

    I have a template level user macros defined, i.e. {$MY_MACROS1}="foo".
    For a particular host I need to declare a user macros with the same name {$MY_MACROS1}. And set it to the template level {$MY_MACROS1} value, concatenated with some host-wise string.
    I.e., on host level: {$MY_MACROS1}={$MY_MACROS1}||" bar".
    So I expect that on my host level the {$MY_MACROS1} will be resolved to value "foo,bar".


  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    on host level you can list all those "inherited" macros and change their values... So the tempalte level macro becomes host level macro... as host level macro is used first (https://www.zabbix.com/documentation...os/user_macros), then everything is just as you need it ..
    Zabbix resolves macros according to the following precedence:
    1. host level macros (checked first)
    2. macros defined for first level templates of the host (i.e., templates linked directly to the host), sorted by template ID
    3. macros defined for second level templates of the host, sorted by template ID
    4. macros defined for third level templates of the host, sorted by template ID, etc.
    5. global macros (checked last)

    In other words, if a macro does not exist for a host, Zabbix will try to find it in the host templates of increasing depth. If still not found, a global macro will be used, if exists.

    Comment

    Working...