Ad Widget

Collapse

How to check which templates are used by each/all hosts

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • greavette
    Member
    • Jul 2015
    • 82

    #1

    How to check which templates are used by each/all hosts

    Hello,

    We have Zabbix 5 LTS installed monitoring around 50 hosts. I'd like to know if there is a command or way to list or report all my current hosts and the templates each host has assigned.

    Thank you.
  • Answer selected by greavette at 08-08-2022, 16:38.
    vladimir_lv
    Senior Member
    • May 2022
    • 240

    The same query shows a linked template. of course, a little bit is uncomfortable that the parent template is shown in the host column. Add %% to '{#'; to avoid of macros

    Code:
    SELECT s.hostid,h1.name as host,s.name as template from hosts as h1 LEFT JOIN (select ht.hostid,hs.name from hosts_templates as ht inner join hosts as hs on ht.templateid=hs.hostid) as s on s.hostid=h1.hostid where s.name is not Null and h1.name not like '%{#%';

    Comment

    • vladimir_lv
      Senior Member
      • May 2022
      • 240

      #2
      I understand that somewhere in the world exists much better way, but this one work as well

      Code:
      SELECT s.hostid,h1.name as host,s.name as template from hosts as h1 LEFT JOIN (select ht.hostid,hs.name from hosts_templates as ht inner join hosts as hs on ht.templateid=hs.hostid) as s on s.hostid=h1.hostid where s.name is not Null and h1.name not like '{#';

      Comment

      • greavette
        Member
        • Jul 2015
        • 82

        #3
        Hello Vladmir, really appreciate your reply...thanks!

        I've run your select statement and this does appear to give me what I need! I've noticed that some templates are linked. is there something that can be added to this select statement you provided that will also show templates used and any linked templates as well?

        Thank you.

        Comment

        • vladimir_lv
          Senior Member
          • May 2022
          • 240

          #4
          The same query shows a linked template. of course, a little bit is uncomfortable that the parent template is shown in the host column. Add %% to '{#'; to avoid of macros

          Code:
          SELECT s.hostid,h1.name as host,s.name as template from hosts as h1 LEFT JOIN (select ht.hostid,hs.name from hosts_templates as ht inner join hosts as hs on ht.templateid=hs.hostid) as s on s.hostid=h1.hostid where s.name is not Null and h1.name not like '%{#%';

          Comment

          • greavette
            Member
            • Jul 2015
            • 82

            #5
            Originally posted by vladimir_lv
            The same query shows a linked template. of course, a little bit is uncomfortable that the parent template is shown in the host column. Add %% to '{#'; to avoid of macros

            Code:
            SELECT s.hostid,h1.name as host,s.name as template from hosts as h1 LEFT JOIN (select ht.hostid,hs.name from hosts_templates as ht inner join hosts as hs on ht.templateid=hs.hostid) as s on s.hostid=h1.hostid where s.name is not Null and h1.name not like '%{#%';
            Thanks very much Vladmir for your help!

            Comment

            Working...