Transforms - SNMP MIB Description

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

Zenoss already does MIB decoding. You shouldn't need the vendor's description on every single trap. The below transform should NOT be used as is at scale ie in a zenoss production environment on /Unknown. Work out what subset of OIDs you really care about and target the transform specifically to those OIDs. Any time you have a transform calling 'dmd' and iterating through results, you're at significant risk of performance problems.

If you want traps to include the vendor's description from the MIB file, if available, put the following code into your /Unknown event class transform:

# the code below takes SNMP traps, finds the MIB in zenoss, and appends the vendor's description from the MIB to the trap text    
if evt.summary.startswith("snmp trap "):
   oid = getattr(evt, 'oid', None)
   if oid:
      for brain in [ b for b in dmd.Mibs.mibSearch() if b.oid]:
           if brain.oid == oid:
              description = brain.getObject().description
              evt.message = "Trap Name: \n\n" + evt.message + "\n\nVendor's Explanation of trap meaning from MIB file: \n\n" + description
              evt.summary = evt.summary + ": " + description