How to get SNMP OIDs (not only values) from plugin?

Hi everyone,

I am currently writing my first SNMP-based cmk plugin. The goal is to monitor line quality metrics of Tunnels configured between Cisco Switches for indicators like latency or loss.

For this to work, I need to process two different OID subtrees:

  • .1.3.6.1.4.1.9.9.1001.1.2.1.7 to get a list of tunnels and their media type
  • .1.3.6.1.4.1.9.9.1001.1.5.1 to get the line quality metrics per tunnel

Some of the info I need (like the local IP and the peer IP the tunnel is established between) are part of dynamically created OIDs. An example data set looks like this: .1.3.6.1.4.1.9.9.1001.1.2.1.7.4.61.62.63.64.4.71.72.73.74.12346.12346.2 4. Here, 61.62.63.64 is the local IP and 71.72.73.74 is the remote IP. For my tests to work, I need to craft these tunnel lists, based on the existing OIDs, not specific OID values. How can I receive these OID lists (not their values) in a checkmk Plugin?

BR,
Marc

You can use OIDEnd() in the your SNMPTree for this i.e.:

fetch=SNMPTree(
              base='.1.3.6.1.4.1.9.9.187.1.2.5.1',  # CISCO-BGP4-MIB::cbgpPeer2Entry
                 oids=[
                    OIDEnd(),
                     '3',  # cbgpPeer2State
                ]
           )

From the Check API doc

classOIDEnd
Bases: cmk.base.api.agent_based.type_defs.OIDSpecTuple

Class to indicate the end of the OID string should be provided

When specifying an OID in an SNMPTree object, the parse function will be handed the corresponding value of that OID. If you use OIDEnd() instead, the parse function will be given the tailing portion of the OID (the part that you not already know).
2 Likes

Baaam!
Not only is this the perfect solution, but also very easy to understand and it took you just a few minutes to read my question and post your answer. Killer! :slight_smile:

Thank you very much, @thl-cmk !

1 Like