I have many custom mib files compiled into pysnmp required format and stored under a directory. I am trying to load them and pickup only those who are of type NotificationType(). By default it will include everything
How can I accomplish this? This is what I am talking about (For example snmpAgentNotResponding event):
from pysnmp.smi import builder, view
mibBuilder = builder.MibBuilder().loadModules('entuity-mib')
mibView = view.MibViewController(mibBuilder)
>>> a = mibView.mibBuilder.mibSymbols
>>> a.keys()
['ENTUITY-MIB', 'ASN1-REFINEMENT', 'RFC1155-SMI', 'ASN1', 'RFC-1212', 'SNMPv2-SMI', 'RFC-1215', 'ASN1-ENUMERATION', 'RFC1213-MIB']
>>> a['ENTUITY-MIB']['snmpAgentNotResponding']
NotificationType((1, 3, 6, 1, 4, 1, 2626, 1, 1, 1, 0, 655363))
I know that this is not a good idea (compare based on the class name) but this what I have so far to achieve this.
>>> b = a['ENTUITY-MIB']['snmpAgentNotResponding']
>>> b.__class__.__name__
'NotificationType'
This is my code to walk over the mib file (from pysnmp forums).
oid, label, suffix = mibView.getFirstNodeName()
while True:
try:
modName, nodeDesc, suffix = mibView.getNodeLocation(oid)
print '%s::%s == %s' % (modName, nodeDesc, oid)
oid, label, suffix = mibView.getNextNodeName(oid)
except Exception, e:
print e
break
How to pick only the NotificationTypes in a better way? Different mib files uses different RFC imports for NotificationTypes. This is where I got confused.