Ad Widget

Collapse

Extra character "\" being inserted when key item is generated during json response

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dcfasika
    Junior Member
    • Oct 2020
    • 4

    #1

    Extra character "\" being inserted when key item is generated during json response

    We're using Zabbix 5.0.5.
    1) Created a php script which returns interface name and OID number. Essentially, the interface name and OID number will be used to check status. Below is the output of the JSON

    {
    "data": [
    {
    "snmpindex": "1.1.1.4.15.192.63.129.1.4.10.193.254.20",
    "bfdinfname": "interface-loop"
    },
    {
    "snmpindex": "20.5.1.4.169.254.255.2.1.4.9.254.255.9",
    "bfdinfname": "interface-internet"
    },
    {
    "snmpindex": "23.171.1.4.169.254.255.44.1.4.169.254.255.61" ,
    "bfdinfname": "interface-cloud"
    }
    ]
    }

    2) Created discovery Rule
    -> Key: script.php
    -> Type: External Script

    3) Also created LLD Macros under discovery rule
    -> LLD MACRO: {#BFDINTFNAME} JSON Path: $..bfdinfname
    -> LLD MACRO: {#SNMPINDEX} JSON Path: $..snmpindex

    4) Created Item Prototype
    -> Type: SNMP Agent
    -> Key: BFDIntfName.[{#BFDINTFNAME}]
    -> SNMP OID: .1.3.6.1.4.1.6527.3.1.2.3.92.1.7.0.0.{#SNMPINDEX}

    So it is able to build the items but it adds extra backslash so when zabbix attempts to snmpwalk on the OID it fails. Below is how the keys are built under item.

    BFDIntfName.["["interface-loop"]"]
    BFDIntfName.["["interface-internet"]"]
    BFDIntfName.["["interface-cloud"]"]

    And the OID looks like this: OID ".1.3.6.1.4.1.6527.3.1.2.3.92.1.7.0.0.["23.171.1.4.169.254.255.44.1.4.169.254.255.61"]

    I cannot seem to understand why it's adding extra bracket and quote in the OID and also extra bracket for the BFDIntfName key. What it should look like is the below.

    BFDIntfName.interface-loop
    BFDIntfName.interface-internet
    BFDIntfName.interface-cloud

    And OID should look like this.

    ".1.3.6.1.4.1.6527.3.1.2.3.92.1.7.0.0.23.171.1.4.1 69.254.255.44.1.4.169.254.255.61"

    Can you please help with as we have been working on this for awhile. Thank you so much.
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    Try use $.bfdinfname (single dot) in LLD macros rule

    Comment

    • dcfasika
      Junior Member
      • Oct 2020
      • 4

      #3
      Thank you so much Hamardaban. Don't understand the logic behind it since one dot won't work if json validation or search tool is used. As long as it works that's all that matters. Thanks again.

      Comment

      Working...