Ad Widget

Collapse

Link Different Templates Dependent Upon Item Value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jwalto01
    Junior Member
    • Nov 2017
    • 5

    #1

    Link Different Templates Dependent Upon Item Value

    Hello All,

    I have a set of equipment that I need to dynamically link the correct templates to. All hosts will be added with one template containing an item which does an SNMP check to grab the model information. Then, based on the item value, I'd like to apply a model-specific template to each. Below is an example of what functionality I'm trying to achieve:

    1.
    Add hosts (5 different models of netwk switch) all linked with one generic template containing an itemX

    2.
    If itemX.val == "A" --> Link template A
    If itemX.Val == "B" --> Link template B
    If itemX.Val == "C" --> Link template C

    I've looked into discovery rules with a discovery action to link templates, but I need control over which hosts are added/removed and when. And unfortunately, it appears that trigger event actions to not support template linking.

    Any thoughts on how to accomplish the above?

    Thanks in advance!
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    At the moment it is not possible to do this.
    Nevertheless it is possible to have something very close what you want but other way.
    Simple now is possible to define LLD which using item which on one case will produce empty json list and in other scenario json with one element on the list.
    Such null/single json list could be used on populate or not some number of items, graphs, screens, triggers ..

    If you will have three LLD which will be using system.run[] and as parameter oneliner sh script which will produce empty or not json list it could be used with checking three times the same probe and check it against the three different values.

    In my OS Solaris template which you can find on https://github.com/kloczek/zabbix-te...r/OS%20Solaris you can find ZFS::L2ARC: LLD which depends o fact is on system is used L2ARC dev or not populates L2ARC monitoring metrics.
    Code:
    system.run["kstat -p zfs::arcstats:l2_hdr_size|awk '/(.*\t0$)/{print \"{\\"data\\":[ ]}\"} !/(.*\t0$)/{print \"{\\"data\\":[{\\"{#L2ARC}\\":\\"*\\"}]}\"}''"]
    So command ("kstat -p zfs::arcstats:l2_hdr_size") executed on monitored host side may return string with "0" or not at the end. If it i "0" it returns empty json "{\"data\":[ ]}". Itf it is non-zero it populates list with one entry with "{#L2ARC}" name and "*" as a value.
    Depends is it L2ARC used by a system this LLD populates 5 items and one graph or nothing.
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment

    • jwalto01
      Junior Member
      • Nov 2017
      • 5

      #3
      Thank you for the reply! I understand the concept of what you're suggesting, but unfortunately that won't work in our situation.

      The devices are Cisco switches on which we cannot run scripts. The only way we get information from them is via SNMP.

      Comment

      Working...