Ad Widget

Collapse

Global Macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lucac
    Junior Member
    • Sep 2013
    • 20

    #1

    Global Macro

    Hi All,
    I would use a global macro that can be used across multiple templates.

    I stumbled across this point in the manual:

    If a user macro is used in items or triggers in a template, it is suggested to add that macro to the template even if it is defined on a global level

    But, if I define the macro at the template level, then global value is not used. Is there a way to keep the macro defined at the template level (so that the template can be exported/imported without issues) but have this value overwritten by the global one?
    TIA
  • kaspars.mednis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2017
    • 349

    #2
    Global Macros are overwritten in the following way

    Host overwrites template, template overwrites global
    lets make an example

    You can have a global macro {$MAX_CPU_LOAD} = 0.5

    then you have 2 templates

    TEST_SYSTEMS without this value, all hosts in this template take it from global macro
    PROD_SYSTEMS with macro {$MAX_CPU_LOAD} = 1, which overwrites global macro and affects all hosts in this template

    and in PROD_SYSTEMS you can have some host with heavy CPU load all the time which is normal for that particular host. Here you overwrite the Template macro on host level with {$MAX_CPU_LOAD} = 3, to make exclusion only for this one host

    This is by design !


    Regards,
    Kaspars

    Comment

    • lucac
      Junior Member
      • Sep 2013
      • 20

      #3
      Hi Kaspars,
      Thanks for reply, but probably I wasn't clear in my post.

      Based on your example, in the TEST_SYSTEMS template the macro is not defined.
      So if I export TEST_SYSTEMS then I won't be able to import it on another server without first creating the global macro MAX_CPU_LOAD.

      Is that correct? From online docs it seems to me that you should always define a macro ALSO at template level to avoid issues when exporting/importing, but probably I missed the point.

      Thanks

      Comment

      • kaspars.mednis
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2017
        • 349

        #4
        Yes, the global macros are not exported with template, so its always better to create them with template if you want to export



        If a user macro is used in items or triggers in a template, it is suggested to add that macro to the template even if it is defined on a global level. That way, exporting the template to XML and importing it in another system will still allow it to work as expected.
        Regards,
        Kaspars

        Comment

        • lucac
          Junior Member
          • Sep 2013
          • 20

          #5
          OK.
          Probably the phrase in doc should be changed in:

          If you want to export the template, it is suggested to define the macro at the template level. That way, exporting the template to XML and importing it in another system will still allow it to work as expected.

          The verb add was confusing me.
          Thanks for clarifying

          Comment

          Working...