Ad Widget

Collapse

Use of macros in host prototypes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gramj
    Junior Member
    • Aug 2016
    • 4

    #1

    Use of macros in host prototypes

    Zabbix v5.4.1

    I am beginning to work with host prototypes. I can create the hosts, attached templates to them, have them collect data, I'm all good there. When it comes to naming the host I can successfully use an LLD macros such as {#MACRO_NAME}, but I can't seem to make use of something like {HOST.NAME}. The hosts that I am creating via LLD have a tight relationship to the discovering host and I want to embed the name of that host in the prototype host. In this case the LLD comes from a template so I don't just want to hard code the LLD with a hostname, hence my desire to use something like {HOST.NAME}. I've also tried using the other type of macro, for example {$HOST_NAME} with that macro value being set on the discovering host.

    What I currently end up with is a discovered host whose name has an unresolved/untranslated macro name.

    Anybody know how to do this?

    Thanks,
    Graham
  • gramj
    Junior Member
    • Aug 2016
    • 4

    #2
    My experience seems to confirm that. Oddly though your statement isn't 100% accurate is the process is happy to assign the same SNMP interface information, proxy server, etc. It's too bad in this case that I can't reference information from the host that is performing the discovery; that would have been an easy and elegant solution and likely useful in many situations. Because of how SNMP discovery seems to work, wherein all OIDs need to having a matching index, it isn't obvious to me that I could do this. Had my discovery been based on JSON or something, I'm sure that I could do something that would have worked. I guess if it comes to it, I could utilize a script to perform the discovery, 3 Low-level discovery [Zabbix Documentation 5.4]. I can't seem to find any documentation quickly as to what parameters I can pass to the script. Will it just be the same sort of parameters that are available when using an external script for a conventional item?

    Comment

    • gramj
      Junior Member
      • Aug 2016
      • 4

      #3
      Thank, cyber. I appreciate your responses.

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Do I get it correctly... you want to add discovery rule to a host, which will then generate another host based on prototype in discovery and use original hosts name while naming that host, created by discovery?
        I am pretty sure it will not work that way... All prototypes depend on data coming from discovery. If your discovery does not give out that needed name as LLD macro you cannot use it in naming of a host created by discovery and host prototype...

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          As discovery rule is also "item", then it depends on its type, what and how you can give it to as parameters... if its an external script, then configure it as any other item with that type... If its agent or agent active item, then configure it as any other similar... You probably need to introduce a UserParameter to agent and feed it with needed parameters. etc
          Custom LLD script has to return json. Examples there in docs use already formed LLD macros as keys, so you don't have to use that LLD macros part to point out with jsonpath where to to find specific key. But you can easily use "normal" key names.. just need to define your LLD macros and path to them in discovery rule...
          For external script you can pass hosts name as parameter, make that script to return it in json.. map to LLD macro and use it in naming... yes.. a bit "around the corner"...but doable.

          Comment

          • gramj
            Junior Member
            • Aug 2016
            • 4

            #6
            I did end up writing an external script using python that performs the discovery using SNMP, and is thus able to correlate data in a manner that is more complex than allowed by normal LLD, and then just return the data. It works in a manner that is consistent with what you described.

            Comment

            • elmorekevin
              Junior Member
              • Feb 2018
              • 15

              #7
              I found two similar feature requests, anyone reading this thread please add a vote.

              Comment

              Working...