Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-4497

Pattern-based conversion of hex to decimal in discovery rule

XMLWordPrintable

    • Icon: Change Request Change Request
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 3.4.8
    • Server (S)
    • CentOS 7

      I'm attempting to use Zabbix to monitor numerous BGP peering links on Cisco routers. These include IPv6 peers. Due to the quantity of interfaces, I'd prefer to not have to manually define items and triggers on a per-router basis, so I'm attempting to use discovery rules. Here is the issue:

      1) If you were doing the above in an IPv4 world, you'd use the standard BGP4-MIB that's been around forever, query OID .1.3.6.1.2.1.15.3.1.7 aka BGP4-MIB::bgpPeerRemoteAddr, and it will spit back a list of IPv4 addresses that are peered with the router in question.

      All the OID's related to data on those peer sessions are keyed off the IP address, so a Zabbix discovery rule and item prototype is very simple. You query the above, get back the IP's in dotted decimal form, which maps to their use in various other OID's, then build your item prototypes around the address inserted in as a variable.

      2) The problem with IPv6 peers is they're hexadecimal numbers, so they cannot be used directly in an OID string. Each network vendor does it differently, but in the case of Cisco, you'd use their CISCO-BGP4-MIB mib and query OID .1.3.6.1.4.1.9.9.187.1.2.5.1.6.2.16. This will give you back the hexadecimal digits of each BGP peer, but unfortunately, space separated instead of dot.

      So, the result must be translated from hex to decimal before you can use it in an item prototype, and then each digit must have its separator changed from space to dot.

      I would love a method for doing string manipulation at the discovery rule level, or perhaps call a program to manipulate the resulting value before it's stored. For example, this is my current discovery rule SNMP OID for IPv6 peer discovery:

      discovery[

      {#SNMPVALUE}

      ,.1.3.6.1.4.1.9.9.187.1.2.5.1.3.2.16]

      I'd envision having been able to pre-define a shell script, or built-in pattern replacement language, to pipe the result through it before assigning to the variable. A very simple couple commands like this will convert the IPv6 hex data to the relevant dotted decimal OID:

      gawk --non-decimal-data 'BEGIN

      {OFS=FS} {for(i=1;i<17;i++) $i=sprintf("%d","0x"$i)}

      1' | tr ' ' '.'

            Unassigned Unassigned
            colohost Colo Host
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: