Re: [pysnmp-users] TrapPDUAPI instance has no attribute 'getEnterprise'
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2015-12-20 12:32:51
|
Hi Gilmar, That happens whenever your Notification Receiver gets SNMPv2 TRAP PDU and handles it as SNMPv1 PDU. If it receives SNMPv1 TRAP PDU, that failure won’t happen. The reason is that SNMPv1 TRAP PDU is very different from one defined in later SNMP versions, so it has different API. You could either disable SNMPv2 support in your script or access SNMPv1 TRAP PDU items conditionally. Or, better yet, use a higher-level and multi-version Notification Receiver: http://pysnmp.sourceforge.net/examples/v3arch/asyncore/contents.html#notification-receiver-applications <http://pysnmp.sourceforge.net/examples/v3arch/asyncore/contents.html#notification-receiver-applications> Besides supporting all SNMP versions out-of-the-box, it will automatically translate SNMPv1 TRAP PDU into SNMPv2 TRAP PDU so your code won’t have to deal with the differences. > On 18 Dec 2015, at 23:54, Gilmar Sinhorin <gil...@er...> wrote: > > Hi All, > I would like your help to figure out the problem I am experiencing for getting the enterprise. I am using the Notification Receiver code from this link > http://pysnmp.sourceforge.net/examples/current/v1arch/manager/ntfrcv/v2c-multiple-transports.html <http://pysnmp.sourceforge.net/examples/current/v1arch/manager/ntfrcv/v2c-multiple-transports.html>. I also get the AgentAddr, GenericTrap, SpecificTrap, TimeStamp attributes failed to be fetching. The getVarBindList method is working. > > I copied an past the trace logs when the failure happened. I hope it helps identify the issue. > > Please let me know if you need further detail. > > Thanks in advance for your help. > Regards, > Gilmar Sinhorin > > --------------------------------------------------------------------------------------------------------------------------------------- > > Traceback (most recent call last): > File "/usr/lib/python2.7/pdb.py", line 1314, in main > pdb._runscript(mainpyfile) > File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript > self.run(statement) > File "/usr/lib/python2.7/bdb.py", line 400, in run > exec cmd in globals, locals > File "<string>", line 1, in <module> > File "ntfyReceiverV02.py", line 11, in <module> > ''' > File "/usr/lib/python2.7/dist-packages/pysnmp/carrier/asynsock/dispatch.py", line 33, in runDispatcher > poll(timeout and timeout or self.timeout, self.__sockMap) > File "/usr/lib/python2.7/asyncore.py", line 156, in poll > read(obj) > File "/usr/lib/python2.7/asyncore.py", line 87, in read > obj.handle_error() > File "/usr/lib/python2.7/asyncore.py", line 83, in read > obj.handle_read_event() > File "/usr/lib/python2.7/asyncore.py", line 447, in handle_read_event > self.handle_read() > File "/usr/lib/python2.7/dist-packages/pysnmp/carrier/asynsock/dgram/base.py", line 73, in handle_read > self._cbFun(self, transportAddress, incomingMessage) > File "/usr/lib/python2.7/dist-packages/pysnmp/carrier/base.py", line 46, in _cbFun > self, transportDomain, transportAddress, incomingMessage > File "ntfyReceiverV02.py", line 44, in cbFun > print('Enterprise: %s' % (trapPDU.getEnterprise(reqPDU).prettyPrint())) > AttributeError: TrapPDUAPI instance has no attribute 'getEnterprise' > Uncaught exception. Entering post mortem debugging > Running 'cont' or 'step' will restart the program |