Ad Widget

Collapse

Discovery of SNMP OIDs prototype

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tex74
    Junior Member
    • Dec 2021
    • 22

    #1

    Discovery of SNMP OIDs prototype

    Hi,

    I try to work with SNMP discovery https://www.zabbix.com/documentation...snmp_oids_walk
    Everything works fine until creating dependent item prototypes. I don't know what I'm missing:

    1) I created the item:
    Click image for larger version

Name:	20250113_143426.jpg
Views:	321
Size:	49.5 KB
ID:	497113

    It works fine and I get a result like this:
    STORMSHIELD-HA-MIB::snsNbNode.0 = INTEGER: 2
    STORMSHIELD-HA-MIB::snsNbDeadNode.0 = INTEGER: 1
    STORMSHIELD-HA-MIB::snsNbActiveNode.0 = INTEGER: 1
    STORMSHIELD-HA-MIB::snsNbHALinks.0 = INTEGER: 1
    STORMSHIELD-HA-MIB::snsNbFaultyHALinks.0 = INTEGER: 1
    STORMSHIELD-HA-MIB::snsNodeIndex.0 = INTEGER: 0
    STORMSHIELD-HA-MIB::snsNodeIndex.1 = INTEGER: 1
    STORMSHIELD-HA-MIB::snsFwSerial.0 = STRING: "XXX"
    STORMSHIELD-HA-MIB::snsFwSerial.1 = STRING: "YYY"
    STORMSHIELD-HA-MIB::snsOnline.0 = INTEGER: true(1)
    STORMSHIELD-HA-MIB::snsOnline.1 = INTEGER: false(2)
    ....

    2) Then I created my discovery rule:
    Click image for larger version

Name:	20250113_143626.jpg
Views:	235
Size:	51.6 KB
ID:	497114
    Click image for larger version

Name:	20250113_143919.jpg
Views:	228
Size:	103.5 KB
ID:	497115

    Test works fine and I get:
    [{"{#SNMPINDEX}":"0","{#SN.SERIAL}":"XXX","{#SN. ONL INE}":"1","{#SN.VERSION}":"ABC","{#SN.LICENCE}":"M aster","{#SN.HEALTH}":"Major"},{"{#SNMPINDEX}":"1" ,"{#SN.SERIAL}":"YYY","{#SN.ONLINE}":"2","{#SN. VER SION}":"","{#SN.LICENCE}":"Unknown"}]

    3) Then I finaly create a dependent item prototype:

    Click image for larger version

Name:	20250113_151040.jpg
Views:	222
Size:	48.4 KB
ID:	497116

    preprocessing: Tried different thing readed on the web. This last works in test mode with JSON in values.
    Click image for larger version

Name:	20250113_151140.jpg
Views:	230
Size:	37.6 KB
ID:	497117

    My problem is that it doesn't work in real life, It seems my item prototype is using with what the early item returns (could be logical 'cause it's the master item...).
    So, can anyone helps me finding what I'm missing. I don't know how to refer to discovery macros in this dependent item prototype

    Thanks a lot
  • Answer selected by Tex74 at 10-03-2025, 15:17.
    Tex74
    Junior Member
    • Dec 2021
    • 22

    HI,

    I finaly find out.
    As I said, it couldn't be anything else than a misunderstand of how things work.

    So, the dependant Item preprocessing must be configure as a "value of SNMP walk" with the OID as parameter.

    Hope this help...

    Comment

    • Tex74
      Junior Member
      • Dec 2021
      • 22

      #2
      Sorry, I forgot to post the error:
      Click image for larger version

Name:	20250113_153101.jpg
Views:	237
Size:	86.6 KB
ID:	497119

      Without preprocessing in item prototype, it returns the whole early item without error.

      Comment

      • Tex74
        Junior Member
        • Dec 2021
        • 22

        #3
        Hi all,

        No one to explain how to use lld macro in item prototype?
        I am surely turning around a so simple solution.

        Thanks in advance

        Comment

        • PZakrzewski
          Junior Member
          • Dec 2024
          • 12

          #4
          Hi,

          It seems the issue lies in the way the dependent item prototypes are handling discovery macros. Here are some key points to check:

          1. Discovery Macros: Ensure the item prototype uses the correct discovery macros like {#SNMPINDEX} in its key and preprocessing steps. Macros are resolved only during runtime for each discovered entity.
          2. Preprocessing: Use “JSONPath” or “Regex” to extract specific values. Example JSONPath:

          Code:
          $[?(@["SNMPINDEX"] == "{#SNMPINDEX}")].snsFwSerial
          Replace snsFwSerial with the desired OID.

          3. Test Preprocessing: Use the “Test” button in the item prototype to confirm that the macros resolve correctly and return the expected values.
          4. Master Item Relation: Ensure the prototype is linked to the discovery rule, as macros won’t work outside its context.

          If you still face issues, please share the exact error or logs for further assistance.
          Cheers!

          Comment

          • Tex74
            Junior Member
            • Dec 2021
            • 22

            #5
            Hi,

            Thanks for your reply.

            "Ensure the prototype is linked to the discovery rule": As my Item prototype has been created inside a discovery rule, It is linked, yes?
            I can't see another way inside the prototype to link it to the discovery rule. It's a dependent item and the master item is the first one I made. The one that results the snmp walk.

            To resume:
            1. An Item "HA INFO", SNMP agent with a walk. The result is:
            Code:
            .1.3.6.1.4.1.11256.1.11.1.0 = INTEGER: 2
            .1.3.6.1.4.1.11256.1.11.2.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.3.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.5.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.6.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.7.1.1.0 = INTEGER: 0
            .1.3.6.1.4.1.11256.1.11.7.1.1.1 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.7.1.2.0 = STRING: "XXX"
            .1.3.6.1.4.1.11256.1.11.7.1.2.1 = STRING: "YYY"
            .1.3.6.1.4.1.11256.1.11.7.1.3.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.7.1.3.1 = INTEGER: 2
            .1.3.6.1.4.1.11256.1.11.7.1.4.0 = STRING: "TOTO"
            .1.3.6.1.4.1.11256.1.11.7.1.4.1 = ""
            .1.3.6.1.4.1.11256.1.11.7.1.5.0 = STRING: "A.B.C"
            .1.3.6.1.4.1.11256.1.11.7.1.5.1 = ""
            .1.3.6.1.4.1.11256.1.11.7.1.6.0 = STRING: "Master"
            .1.3.6.1.4.1.11256.1.11.7.1.6.1 = STRING: "Unknown"
            2. A discovery rule, dependent item of master item "HA INFO", with a preprocessing "SNMP to JSON". The result is:
            Code:
            [{"{#SNMPINDEX}":"0","{#SNSERIAL}":"XXX","{#SNONLINE}":"1","{#SNVERSION}":"A.B.C","{#SNLICENCE}":"Master"},{"{#SNMPINDEX}":"1","{#SNSERIAL}":"YYY","{#SNONLINE}":"2","{#SNVERSION}":"","{#SNLICENCE}":"Unknown"}]
            3. A item prototype, dependent item of master item "HA INFO", with a preprocessing "JSONPath"
            In test mode, parsing the discovery result, with this syntax:
            Code:
            $[?(@["SNMPINDEX"] == "{#SNMPINDEX}")].1.3.6.1.4.1.11256.1.11.7.1.2.0
            I get
            cannot extract value from json by path "$[?(@["SNMPINDEX"] == "{#SNMPINDEX}")].1.3.6.1.4.1.11256.1.11.7.1.2.0": no data matches the specified path
            Without preprocessing, the prototype creates an item that returns the all master item result. That's also the reason I have items where I can see that {#SNMPINDEX} is working for item name and item key:
            Click image for larger version

Name:	20250123_170816.jpg
Views:	226
Size:	24.0 KB
ID:	497761
            Click image for larger version

Name:	20250123_170711.jpg
Views:	227
Size:	17.9 KB
ID:	497762
            (This means that the macro I want as a value could be writen in the item name withaout any problem. Crazy isn't it?)

            With any preprocessing, the error is:
            Preprocessing failed for: .1.3.6.1.4.1.12345.1.11.1.0 = INTEGER: 2..1.3.6.1.4.1.11256.1.11.2.0 = INTEGER: 1..1.3.6.1.4.1.11...
            1. Failed: cannot extract value from json by path "$[?(@["SNMPINDEX"] == "1")].1.3.6.1.4.1.11256.1.11.7.1.2.0": invalid object format, expected opening character '{' or '[' at: '.1.3.6.1.4.1.11256.1.11.1.0 = INTEGER: 2
            .1.3.6.1.4.1.11256.1.11.2.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.3.0 = INTEGER: 1
            .1.3.6.1.4.1.11256.1.11.5.0 = INTEGER: 1
            This lets me think that prototype works with the master item result and not the discovery result.
            This goes back to "Ensure the prototype is linked to the discovery rule"....

            Thanks for helping

            Comment

            • Tex74
              Junior Member
              • Dec 2021
              • 22

              #6
              HI,

              I finaly find out.
              As I said, it couldn't be anything else than a misunderstand of how things work.

              So, the dependant Item preprocessing must be configure as a "value of SNMP walk" with the OID as parameter.

              Hope this help...

              Comment

              Working...