Reputation: 1249
so I'm trying to get traps working in our project. We are using a custom mib and walking it already works, also sending traps without additional data works fine with the following code and the OBJECT property removed from the trap in the MIB:
def sendEventTrap(self, event):
if(doPrintTraps):
print "Sending trap"
ntfOrg = ntforg.NotificationOriginator(self._snmpContext)
errorIndication = ntfOrg.sendNotification(
self._snmpEngine,
'trap',
('PROJECT-MIB', 'eventTrap'),
())
Now I'm trying to add a simple Integer32 additional object like so
def sendEventTrap(self, event):
if(doPrintTraps):
print "Sending trap"
ntfOrg = ntforg.NotificationOriginator(self._snmpContext)
errorIndication = ntfOrg.sendNotification(
self._snmpEngine,
'trap',
('PROJECT-MIB', 'eventTrap'),
[((1, 3, 6, 1, 4, 1, 999999, 3, 1, 0) , v2c.Integer32(1337))])
However this fails even though according to the following log it does find and match the right OID with the correctly associated Integer32 type: http://pastebin.com/hJ9LAiAg
This is the relevant part of the MIB:
eventNotifications OBJECT IDENTIFIER ::= { xxx 4 }
eventTrap NOTIFICATION-TYPE
OBJECTS { direction }
STATUS current
DESCRIPTION ""
::= {eventNotifications 1}
NOTE some function names have been changed for privacy reasons. I'm at a loss here and would greatly appreciate inputs as to where things are going wrong.
Upvotes: 0
Views: 566
Reputation: 1249
I finally got this working. There were actually two problems.
instanceIndex=(0,)
as a parameter and when sending an already managed object one doesn't have to include it as a varBind by hand.The following works with the declarations as in the questions MIB:
ntfOrg = ntforg.NotificationOriginator(self._snmpContext)
errorIndication = ntfOrg.sendNotification(
self._snmpEngine,
'trap',
('PROJECT-MIB', 'eventTrap'),
instanceIndex=(0,))
Upvotes: 1