Ad Widget

Collapse

Setting macro value by host groups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mzamora
    Junior Member
    • Oct 2017
    • 6

    #1

    Setting macro value by host groups

    Hello, here's my situation.
    I have a base template called "Windows OS Template".
    I have a global macro which is {CPU_CRITICAL} = 75%.

    I have the following host groups and hosts, and they all get applied the base template, "Windows OS Template", where the effective {CPU_CRITICAL} = 75%.

    For example, in PRODUCTION, the default 75% is fine, so I will take the global macro value.
    For, QAT, I want the threshold to be 95%.
    For LAB, I want the threshold to be 99%.
    Whats the best way to achieve this WITHOUT creating multiple templates?
    AND without going to each server's macro and updating it manually?

    Host group: PRODUCTION
    server1
    server2

    Host group: QAT
    server3
    server4

    Host group: LAB
    server5
    server 6
  • kaspars.mednis
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2017
    • 349

    #2
    The macros are defined only in 3 locations

    -Global
    -Template
    -Hosts

    Host groups are used only for logical grouping of hosts, so you must define macros in hosts or templates...

    You can create identical templates PROD,QAT,LAB with different macro values.
    After that, you can move hosts easily between identical templates without loosing historical data by just unlinking and relinking them (do not use unlink and clear button in this case !!!)
    and remember that host macros overwrite template macros, so do not define host macros in this scenario

    Or you can consider writing some API script or updating the database directly by some custom select/update script. Be careful with this, things can be broken very easily with direct DB updates




    regards,
    Kaspars

    Comment

    • mzamora
      Junior Member
      • Oct 2017
      • 6

      #3
      Thanks for your reply. I was hoping I wouldn't have to have identical templates for PROD, QAT and LAB, but it seems that may be the only way to go. Thanks for your response!

      Comment

      • LenR
        Senior Member
        • Sep 2009
        • 1005

        #4
        I think you can create the 3 templates with only your macro and link a common template behind those for less complicated work.

        Comment

        • mzamora
          Junior Member
          • Oct 2017
          • 6

          #5
          Thanks I'm going to try that. I have not tested if a template require items or triggers, or if it can just have macros only.

          Comment

          • mzamora
            Junior Member
            • Oct 2017
            • 6

            #6
            I'm running into template precedence issues now.
            I've linked 2 templates to a host. Both have a macro called {CPU_CRITICAL}.
            The first template has ID of 10319 with {CPU_CRITICAL} set to 75
            The second template has ID of 12109 with {CPU_CRITICAL} set to 50

            The effective macro is 75. I need the effective macro value to be that of the second template, with value set to 50. It seems that template macro values are set based on the lowest template ID. Any idea how to get around this?

            Comment

            Working...