Ad Widget

Collapse

Using LLD Macro in another LLD rule

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fabg
    Junior Member
    • Jan 2024
    • 2

    #1

    Using LLD Macro in another LLD rule

    Hi all,

    Looking for some guidance if it is possible to use macros defined in an LLD rule in another LLD rule.

    What I am looking to do has 2 steps:

    LLD rule #1: Discovery all sensors. Output is similar to that:

    Code:
    [
        {
            "{#SENSORNAME}": "sensor1",
            "{#SENSORSN}": "E176A170500000"
        },
        {
            "{#SENSORNAME}": "sensor2",
            "{#SENSORSN}": "9790987839"
        }
    ]
    LLD rule #2: For each sensor discovered, list all network interfaces that are UP.

    Can we do that? I am not able to make this work..


    I also tried a different way where I use only 1 LLD and end up with this type of output:

    Code:
    [
        {
            "{#SENSORNAME}": "sensor1",
            "{#SENSORSN}": "E176A170500000",
            "{#INTF_LIST}": [
                "eth0",
                "eth2"
            ]
        },
        {
            "{#SENSORNAME}": "sensor2",
            "{#SENSORSN}": "9790987839",
            "{#INTF_LIST}": [
                "eth0"
            ]
        }
    ]​
    But I dont think it exists a way to iterate through "INTF_LIST" on a prototype items.

    Any help is appreciated
  • Answer selected by fabg at 12-01-2024, 22:37.
    Brambo
    Senior Member
    • Jul 2023
    • 245

    So with rule 1 you want to do host prototype?
    Then you must apply a template to the new host where again with LLD you do the INFT list discocery and do a ITEM prototype to populate the correct items. I don't how (AND why) you would want to do this.

    PS not sure if you send this data with zabbix_sender but if you do my experience is that you better not send it with macro's but used LLD macro's of your discovery rule to match it. (I have been on that route and run into issues )

    Comment

    • Brambo
      Senior Member
      • Jul 2023
      • 245

      #2
      So with rule 1 you want to do host prototype?
      Then you must apply a template to the new host where again with LLD you do the INFT list discocery and do a ITEM prototype to populate the correct items. I don't how (AND why) you would want to do this.

      PS not sure if you send this data with zabbix_sender but if you do my experience is that you better not send it with macro's but used LLD macro's of your discovery rule to match it. (I have been on that route and run into issues )

      Comment

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

        #3
        yeah.. using LLD macros as json key names, bad juju coming your way... specially, if you want to construct some jsonpaths at one point... then it cannot make up is it a key or should it be substituted with some value...

        Comment

        • Brambo
          Senior Member
          • Jul 2023
          • 245

          #4
          When you have something like this in host prototype:
          However a step which is easy to forge(also part of the host prototype: Click image for larger version  Name:	image.png Views:	0 Size:	9.5 KB ID:	477049
          And in the template selected (just cut of the screenshot) it's just like any other host-template:
          -above is host prototype---
          When you want value in item prototype:
          Click image for larger version

Name:	image.png
Views:	549
Size:	28.8 KB
ID:	477051​Use the pre-processing to find the value, keep in mind the ' next to the == and at the and of the macro (and yes it can be a puzzle to setup the correct jsonpath.
          But you have to provide full path of the entire jsondata.
          Last edited by Brambo; 12-01-2024, 09:34. Reason: added item prototype value

          Comment

          • fabg
            Junior Member
            • Jan 2024
            • 2

            #5
            Thank you for the guidance!

            I used a Host Prototype rule within my template and used another template with LLD to discover interfaces per sensor. All good

            Comment

            • mixeycray
              Junior Member
              • Jan 2024
              • 1

              #6
              So with rule 1 you want to do host prototype?

              Comment

              Working...