etingof / snmpsim

SNMP Simulator
http://snmplabs.com/snmpsim/
BSD 2-Clause "Simplified" License
383 stars 121 forks source link

snmpwalk terminates snmpsimd process while Simulating SNMP Agents #17

Closed GeorgePapageorgakis closed 7 years ago

GeorgePapageorgakis commented 7 years ago

I have recorded oids from a device, placed the rec file in one of the folders and set up the snmpsimd as snmpsimd --agent-udpv4-endpoint=127.0.0.1:1161 and I get:

...
Listening at UDP/IPv4 endpoint 127.0.0.1:1161, transport ID 1.3.6.1.6.1.1.0

when I do an snmpwalk (also tried snmpget with same results), like: snmpwalk -On -v1 -c recorded/ubnt-system localhost:1161 snmpsimd process is terminated with Traceback list of calls like:

Process terminated
Traceback (most recent call last):;
File "/usr/bin/snmpsimd", line 1281, in <module>;
transportDispatcher.runDispatcher();
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher; raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())));
PySnmpError: poll error: Traceback (most recent call last):;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher; use_poll=True, map=self.__sockMap, count=1);;  
File "/usr/lib/python2.7/asyncore.py", line 220, in loop;    
poll_fun(timeout, map);;  
File "/usr/lib/python2.7/asyncore.py", line 201, in poll2;    readwrite(obj, flags);;  
File "/usr/lib/python2.7/asyncore.py", line 123, in readwrite;    obj.handle_error();;  
File "/usr/lib/python2.7/asyncore.py", line 108, in readwrite;    obj.handle_read_event();;  
File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event;    self.handle_read();;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 163, in handle_read;    self._cbFun(self, transportAddress, incomingMessage);; 
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/carrier/base.py", line 70, in _cbFun;    self, transportDomain, transportAddress, incomingMessage;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/engine.py", line 152, in __receiveMessageCbFun;    self, transportDomain, transportAddress, wholeMsg;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/proto/rfc3412.py", line 433, in receiveMessage;    PDU, maxSizeResponseScopedPDU, stateReference);;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 140, in processPdu;    (self.__verifyAccess, snmpEngine));;  
File "/usr/bin/snmpsimd", line 991, in handleMgmtOperation;    PDU, acInfo;;  
File "/home/ngeo/.local/lib/python2.7/site-packages/pysnmp/entity/rfc3413/cmdrsp.py", line 262, in handleMgmtOperation;    rspVarBinds = mgmtFun(varBinds, (acFun, acCtx));;  
File "/usr/bin/snmpsimd", line 429, in readNextVars;    varBinds, **self.__getCallContext(acInfo, True);;  
File "/usr/bin/snmpsimd", line 410, in __getCallContext;    pduType ) = acCtx  # this is not [yet] documented;;TypeError: 'SnmpEngine' object is not iterable;;
...

Is there something going on with my python modules or with the simulator?

etingof commented 7 years ago

What snmpsim/pysnmp versions you are running?

Could you please upgrade to the latest released version and report back whether it works for you?

GeorgePapageorgakis commented 7 years ago

Thanks for your reply. I am really lost here. I am trying to reinstall it with venv. I will post again soon.

SNMP Simulator version 0.2.4, written by Ilya Etingof <ilya@glas.net>
Using foundation libraries: pysnmp 4.3.9, pyasn1 0.3.2.
Python interpreter: 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
GeorgePapageorgakis commented 7 years ago

Ok just tried it again. I get the same output. My recorded device OIDS are in /usr/share/snmpsim/data/recorded/ubnt-system.snmprec I set up the sim daemon like snmpsimd --agent-udpv4-endpoint=127.0.0.1:1161 and when I do an snmpwalk like:

snmpwalk -On -v1 -c recorded/ubnt-system localhost:1161 1.3.6
Timeout: No Response from localhost:1161

process terminates with a spam of messages as aforementioned.

Is there any chance that there is a conflict between pySNMP and the Net-SNMP tool?

etingof commented 7 years ago

It looks like your snmpsim/pysnmp versions combination is somehow wrong. You should upgrade snmpsim to the latest released version:

$ virtualenv venv
$ . venv/bin/activate
$ pip install snmpsim --upgrade

That way you should get the latest coherent versions of snmpsim and all its dependencies.

GeorgePapageorgakis commented 7 years ago

I followed the steps you proposed:

Collecting snmpsim
  Using cached snmpsim-0.3.1-py2.py3-none-any.whl
Collecting pysnmp>=4.3.0 (from snmpsim)
  Using cached pysnmp-4.3.9-py2.py3-none-any.whl
Collecting pyasn1>=0.2.3 (from pysnmp>=4.3.0->snmpsim)
  Using cached pyasn1-0.3.2-py2.py3-none-any.whl
Collecting pysmi (from pysnmp>=4.3.0->snmpsim)
  Using cached pysmi-0.1.3-py2.py3-none-any.whl
Collecting pycryptodome (from pysnmp>=4.3.0->snmpsim)
Collecting ply (from pysmi->pysnmp>=4.3.0->snmpsim)
Installing collected packages: pyasn1, ply, pysmi, pycryptodome, pysnmp, snmpsim
Successfully installed ply-3.10 pyasn1-0.3.2 pycryptodome-3.4.6 pysmi-0.1.3 pysnmp-4.3.9  snmpsim-0.3.1

(venv) $ snmpsimd --version
SNMP Simulator version 0.2.4, written by Ilya Etingof <ilya@glas.net>
Using foundation libraries: pysnmp 4.3.9, pyasn1 0.3.2.
Python interpreter: 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]

The Problem still persists. Version did not change although it says it successfully installed 0.3.1. Does it have to do with missing libraries or something similar?

etingof commented 7 years ago

Do you experience this issue with any .snmprec file or just with the recorded/ubnt-system one? In the latter case, could you please provide that file so I could reproduce this crash?

I run the same setup and I do not see this happening so far.

GeorgePapageorgakis commented 7 years ago

Have not tried with other device. I removed snmpsimd now and I cannot reinstall it. Requirement already satisfied: .... I think I had conflicted installations, (a normal installation and one in venv). I ll try to check it out as well.

GeorgePapageorgakis commented 7 years ago

Finally fixed. The problem was conflicting installations of venv and wrong versions. Had to uninstall everything and install only in venv. Now seems to work ok in venv. I suggest you edit the installation tutorial a bit so that it has more specific instructions. Thank you very much! Keep up the good work!