Re: [pysnmp-users] TrapPDUAPI instance has no attribute 'getEnterprise'
Brought to you by:
elie
From: Papa <pap...@gm...> - 2015-12-22 20:48:09
|
Gilmar, When I use python and pysnmp, I feel I'm standing on the shoulders of giants. :-) While apt-get is good to update your python or other applications on ubuntu, you depend on what ubuntu makes available. Python uses pip as its own package manager for python packages like pysnmp.. google, bing, etc: on how to use pip. Cheers, 21/12/2015 23:41, Gilmar Sinhorin wrote: > Hi Ilya, > Thanks for the reply. > I modified the code in order to support the SNMP v1 and v2c, I browsed the framework a bit and I thought it was possible, but I was wrong. I would like to tell you that I'm learning the pySNMP framework as I am going. In regarding upgrade the pysnmp to version 4.3, I can upgrade since I keep deploying the python 2.7. I took a quick look in the pysnmp site https://pypi.python.org/pypi/pysnmp/4.3.0 and I attempted to upgrade from ' 4.2.2-1' to 'pysnmp-4.3.0-py2.7.egs' on Ubuntu by use this command 'sudo apt-get install python-pysnmp4=4.3.0 ', but got the message ' Version 4.3.0 for python-pysnmp4 was not found'. I also tried other command combination and didn't work ether. I considered download and install manually, but it seems that the package was packaged to be installed on windows. I would appreciate if you can help me with the steps for upgrade to 'pysnmp-4.3.0-py2.7.egs' on Ubuntu. > > Thanks again for your help. > Regards, > Gilmar Sinhorin > > -----Original Message----- > From: Ilya Etingof [mailto:il...@gl...] > Sent: Monday, December 21, 2015 4:38 AM > To: Gilmar Sinhorin > Cc: pys...@li... > Subject: Re: [pysnmp-users] TrapPDUAPI instance has no attribute 'getEnterprise' > > Hi Gilmar, > > I’ve investigated the issue again and now I can’t see how the code you use: > > http://pysnmp.sourceforge.net/examples/current/v1arch/manager/ntfrcv/v2c-multiple-transports.html > > can possibly fail the way you reported. Is it the exact original code or you have modified it somehow? > In particular, this statement from original code would prevent is from happening: > > if msgVer == api.protoVersion1: > > by not entering into the failing branch if msgVer != 0 (SNMP v1 == 0, v2c == 1). > > Another idea why it could happen is if your trap message has incorrect version indication. That could be figured out by adding: > > print(reqMsg.prerryPrint()) > > anywhere once reqMsg is assigned. > > Speaking of high-level API, if you can’t upgrade to pysnmp 4.3 (which is highly recommended), then you could refer to older examples: > > http://pysnmp.sourceforge.net/examples/current/v3arch/manager/ntfrcv/v2c-multiple-interfaces.html > > (IPv6 part can be dropped from the code above). > > -ilya > >> On 21 Dec 2015, at 04:16, Gilmar Sinhorin <gil...@er...> wrote: >> >> Hi Ilya, >> >> Thanks for the reply. >> >> The script I mentioned below works fine for SNMPv1 only, but the >> problem I need to receive TRAP from both SNMP versions (SNMPv1. >> SNMPv2) >> >> I tried to use the ‘use a higher-level and multi-version Notification Receiver’, but I have problem to import the module ‘from pysnmp.carrier.asyncore.dgram import udp’, which was not found on my environment. >> >> I need to run on Ubuntu VM, which contains installed the pysnmp-4.2.5-py2.7.egg from https://pypi.python.org/simple/pysnmp/ . Can you point to me what is the mandatory packages to run the ‘Notification Receiver’ on Ubuntu? >> >> >> >> Thanks, >> >> Gilmar >> >> From: Ilya Etingof [mailto:il...@gl...] >> Sent: Sunday, December 20, 2015 7:33 AM >> To: Gilmar Sinhorin >> Cc: pys...@li... >> Subject: Re: [pysnmp-users] TrapPDUAPI instance has no attribute 'getEnterprise' >> >> >> >> >> >> 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#n >> otification-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. 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.p >> y", 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 >> > ------------------------------------------------------------------------------ > _______________________________________________ > pysnmp-users mailing list > pys...@li... > https://lists.sourceforge.net/lists/listinfo/pysnmp-users -- mich Mich |