Ad Widget

Collapse

Link templates multiple times with different values for macros

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mwildam
    Member
    • Feb 2021
    • 72

    #1

    Link templates multiple times with different values for macros

    Hi,
    I am pretty new to Zabbix, but I know about the importance to use templates.
    Using 5.2.4, I have created a template for doing checks on a DB2 database.
    My problem now: I have multiple servers/hosts with different databases. In the template I have created macros for {$DBNAME}, {$DBLOCATION}, {$DBUSER} and so on.
    So in reality I would like to link the template multiple times to a host using different values for the macros. This obviously - at least currently - does not work.

    In another attempt I looked at the user macros with context, but I don't think that can solve my issue - at least I have no idea, how.

    I did not find in the documentation any hint, how I can solve such a use case, other than cloning the template (which is no real solution, just a bad workaround as after each change I would need to clone again and relink to the hosts).

    Is there a feature or solution that I have missed?
  • xlu
    Junior Member
    • Dec 2021
    • 1

    #2
    Hello mwildman,

    I am trying to solve the same issue. I use the Db2 template from this repo (https://github.com/digiapulssi/zabbi...toring-scripts). It works OK, but I would like to add there an option to iterate one item (Database status) through the list of selected databases and send an alert in case it is not in Active status.
    Have you already found a solution for this task?

    Thank you

    Comment

    • mwildam
      Member
      • Feb 2021
      • 72

      #3
      I did not really solve the issue. I am using nested templates (having macros in first template defaulting to a separate macro value that comes from the second template on top) but obviously no iteration.

      Comment

      • ISiroshtan
        Senior Member
        • Nov 2019
        • 324

        #4
        xlu sound like you could try to use LLD. You'd need a script that returns list of DBs as a JSON, create item prototype and trigger prototype with whatever checks you want.

        That way discovery should create a separate item and trigger for each object defined in JSON list (for each Database name in your case).

        Also must point that I've not used this specific approach yet, so can not give detailed step-by-step instructions or 100% guarantee that it will work exactly as you want. But this is direction I'd go for.

        Comment

        • mwildam
          Member
          • Feb 2021
          • 72

          #5
          Thanks, that is an insteresting idea/approach - I have used the LLD for other stuff with a self-made script. Indeed could do similar also for the databases. Thanks.

          Comment

          • mattjan
            Junior Member
            • Apr 2021
            • 19

            #6
            It will work, make sure you add Trim -> [] for preprocessing in item prototype if the value is numeric.
            Almost half of my dashboard now full of sql stuff

            Comment

            Working...