简体   繁体   中英

Trap OID to trap name - snmp

There is a set of snmp trap OID's, from different vendor devices like Cisco/Juniper/Arista etc...

For example: 1.3.6.1.4.1.6101.1.8.8.2.1

We would like to know the trap names for each OID. There are more than 300 OID's.


Programmatically we store all trap OID's in set, using python.

What is the best approach to retrieve trap names? Does any public repository provide mapping of trap OID to trap name?

You could run the mibbuild.py --destination-format json tool over all your MIBs. You will get one JSON document for each of your MIB files. The JSON documents will look like this :

"coldStart": {
  "name": "coldStart", 
  "oid": "1.3.6.1.6.3.1.1.5.1", 
  "class": "notificationtype", 
  "status": "current"
}, 

From here you can load JSON into Python, create a new dict like {json[key]['oid']: key for key in json} which you could use for looking up TRAP names by OID.

If your collection of MIBs is changing and needs constant updates, you can build the above procedure into your application by calling pysmi functions.

EDIT:

If you need to resolve whatever TRAP OID into its MIB name, you can grab as many MIBs as you can find on the Internet and run the above procedure over them. However you still may not be able to resolve all TRAP OIDs you encounter in the wild. It is more typical to have MIBs for all the devices your software is managing.

The default for the mibdump tool is to pull requested MIBs from http://mibs.snmplabs.com/asn1/ site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM