snmpsim icon indicating copy to clipboard operation
snmpsim copied to clipboard

variation module not given snmpEngine

Open qrobinson opened this issue 6 years ago • 15 comments

Thanks for writing this Simulator; it is a great software.

Variation module notification.py reports this error when attempting to snmpget the "trigger OID":

2018-03-16 16:14:41,810 snmpsimd: data error at /home/qrobinson/.snmpsim/data/notify.snmprec controller for 1.3.6.1.4.1.5591.1.3.1.1.0: variation module not given snmpEngine

I found a thread dated from Thu, Nov 7 2013 addressing this issue here.
The error persists since updating snmpsim to the latest release (0.4.4) with pip; please advise.

Regards

qrobinson avatar Mar 16 '18 21:03 qrobinson

I can't reproduce this issue with the latest master (which is pretty much the same as 0.4.4):

My SNMP query:

$ snmpget -v2c -c variation/notification  127.0.0.1:1161 1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = STRING: SNMPv1 trap sender

Simulator log:

...
Request var-binds: 1.3.6.1.2.1.1.1.0=<>, flags: EXACT, GET
notification: binding to local address 127.0.0.1
notification: sending Notification to CommunityData(communityIndex='s-9132822542186126193', communityName=<COMMUNITY>, mpModel=0, contextEngineId=None, contextName=b'', tag='819827421720947852', securityName='s-9132822542186126193') with credentials UdpTransportTarget(('127.0.0.1', 162), timeout=1, retries=5, tagList='819827421720947852')
Response var-binds: 1.3.6.1.2.1.1.1.0=<SNMPv1 trap sender>

Could you please make sure that you are running 0.4.4 and the variation modules belong to the same version (because they are loaded dynamically and searched at multiple places):

$ snmpsimd.py --version
SNMP Simulator version 0.4.5, written by Ilya Etingof <[email protected]>
Using foundation libraries: pysnmp 4.4.1, pyasn1 0.3.7.
Python interpreter: 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
...

If you are indeed at 0.4.4, could you help me reproduce it? The exact .snmprec and commands you use might be helpful.

etingof avatar Mar 17 '18 08:03 etingof

Thanks for your response, Ilya. Please reply with any addition information required.

Regards

-- variation module:

$ md5sum $(find /tmp/snmpsim-master/ -name notification.py)
ace0dc84f59d880b68386a1b59255006 /tmp/snmpsim-master/variation/notification.py
$ md5sum /usr/snmpsim/variation/notification.py
ace0dc84f59d880b68386a1b59255006 notification.py
$ md5sum ~/.snmpsim/variation/notification.py
ace0dc84f59d880b68386a1b59255006 /home/qrobinson/.snmpsim/variation/notification.py

snmpsimd version:

$ snmpsimd.py --version
SNMP Simulator version 0.4.4, written by Ilya Etingof <[email protected]>
Using foundation libraries: pysnmp 4.4.4, pyasn1 0.4.2.
Python interpreter: 2.7.13 (default, Dec  1 2017, 09:21:53) 

command & response (per your example):

$ snmpget -v2c -c variation/notification  localhost 1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = No Such Instance currently exists at this OID

snmpsim.log:

snmpsimd: Using /usr/snmpsim/data/variation/notification.snmprec controller selected by candidate variation/notification; transport ID 1.3.6.1.6.1.1.0, source address 127.0.0.1, community name "variation/notification"
snmpsimd: Opening /usr/snmpsim/data/variation/notification.snmprec controller
snmpsimd: Request var-binds: 1.3.6.1.2.1.1.1.0=<>, flags: EXACT, GET
snmpsimd: data error at /usr/snmpsim/data/variation/notification.snmprec controller for 1.3.6.1.2.1.1.1.0: variation module not given snmpEngine
snmpsimd: Response var-binds: 1.3.6.1.2.1.1.1.0=<No Such Instance currently exists at this OID>

qrobinson avatar Mar 17 '18 23:03 qrobinson

Hello Ilya, thank you for writing this great application. I am experiencing the same issue as qrobinson. One out of 19 simulated agents reports "variation module not given snmpEngine". All other agents are OK.

Have you found anything about this issue?

Thank you,

Miro

Mirro888 avatar Jun 13 '18 21:06 Mirro888

I've spent a fair amount of time in the debugger trying to guess how this could possibly happen. But I still have no clue and that's intriguing.

By way of peeking into the code I've added a bit more logging. So one thing I'd propose to do is to take the latest snmpsim master, run into this error and post relevant part of snmpsimd log. Could you guys do that?

The other thing is that with the emergence of pysnmp 5 this notification module is going to be simplified a great deal what may fix this problem as a side effect...

etingof avatar Jul 01 '18 14:07 etingof

Thank you for your attention to this issue, Ilya.
Per instructions, rebuilt from master with setuptools, then reinstalled the variation modules; logs seem unchanged.

$ snmpsimd.py --version
SNMP Simulator version 0.4.5, written by Ilya Etingof <[email protected]>
Using foundation libraries: pysnmp 4.4.4, pyasn1 0.4.2.
Python interpreter: 2.7.13 (default, Dec  1 2017, 09:21:53) 
[GCC 6.4.1 20170727 (Red Hat 6.4.1-1)]
$ md5sum ~/.snmpsim/data/variation/notification.py
2c927e2920a829f97f8cb58d6e8fdb3f  /home/qrobinson/.snmpsim/data/variation/notification.py
$ md5sum $(find ~/downloads/snmpsim-master/ -name notification.py)
2c927e2920a829f97f8cb58d6e8fdb3f  /home/qrobinson/downloads/snmpsim-master/variation/notification.py
$ md5sum /usr/snmpsim/variation/notification.py
2c927e2920a829f97f8cb58d6e8fdb3f  /usr/snmpsim/variation/notification.py
$ snmpget -v2c -c variation/notification  localhost 1.3.6.1.2.1.1.1.0
2018-07-02 09:03:56,660 snmpsimd: Using /home/qrobinson/.snmpsim/data/variation/notification.snmprec controller selected by candidate variation/notification; transport ID 1.3.6.1.6.1.1.0, source address 127.0.0.1, community name "variation/notification"
2018-07-02 09:03:56,660 snmpsimd: Opening /home/qrobinson/.snmpsim/data/variation/notification.snmprec controller
2018-07-02 09:03:56,660 snmpsimd: Request var-binds: 1.3.6.1.2.1.1.1.0=<>, flags: EXACT, GET
2018-07-02 09:03:56,661 snmpsimd: data error at /home/qrobinson/.snmpsim/data/variation/notification.snmprec controller for 1.3.6.1.2.1.1.1.0: variation module not given snmpEngine
2018-07-02 09:03:56,661 snmpsimd: Response var-binds: 1.3.6.1.2.1.1.1.0=<No Such Instance currently exists at this OID>
SNMPv2-MIB::sysDescr.0 = No Such Instance currently exists at this OID

qrobinson avatar Jul 02 '18 13:07 qrobinson

Hello Ilya,

I tried snmpsim 0.4.5 with Python 2.7.5 and Python 3.6.3 on Centos 7.5:

#python3 scripts/snmpsimd.py --version SNMP Simulator version 0.4.5, written by Ilya Etingof [email protected] Using foundation libraries: pysnmp 4.4.4, pyasn1 0.4.3. Python interpreter: 3.6.3 (default, Jan 4 2018, 16:40:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

#python scripts/snmpsimd.py --version
SNMP Simulator version 0.4.5, written by Ilya Etingof [email protected] Using foundation libraries: pysnmp 4.4.4, pyasn1 0.4.3. Python interpreter: 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

I've used a public.snmprec with only 1 line:

1.3.6.1.2.1.2.2.1.7.1|2:notification|version=2c,community=public,proto=udp,host=127.0.0.1,port=162,ntftype=trap,trapoid=1.3.6.1.6.3.1.1.5.3,value=1

Then executed:

snmpget -t 2 -r 0 -ObentU -v2c -c public 127.0.0.1 .1.3.6.1.2.1.2.2.1.7.1

.1.3.6.1.2.1.2.2.1.7.1 = No Such Instance currently exists at this OID

The log shows this:

Listening at UDP/IPv4 endpoint 127.0.0.1, transport ID 1.3.6.1.6.1.1.0
Using /tmp/data/public.snmprec controller selected by candidate b'public'; transport ID 1.3.6.1.6.1.1.0, source address 127.0.0.1, community name "public"
Opening /tmp/data/public.snmprec controller
Request var-binds: 1.3.6.1.2.1.2.2.1.7.1=<>, flags: EXACT, GET
data error at /tmp/data/public.snmprec controller for 1.3.6.1.2.1.2.2.1.7.1: variation module not given snmpEngine
Response var-binds: 1.3.6.1.2.1.2.2.1.7.1=<No Such Instance currently exists at this OID>

Best regards,

Miro

Mirro888 avatar Jul 14 '18 22:07 Mirro888

I've reproduced this issue by running 'snmpsimd --v2c-arch'. Without the --v2c-arch flag, the issue does not occur. My assumption is that when using the --v2c-arch flag, the snmp v3 code is not run at all, and so the SNMPv3 EngineID is not initialized.

remco-dg avatar Jan 10 '19 16:01 remco-dg

Ha, awesome find! Yes, @remco-dg must be right - there is no SNMP engine created with --v2c-arch.

Let me perhaps just make the notification plugin failing clearly on --v2c-arch run.

etingof avatar Jan 10 '19 16:01 etingof

Well, code-wise this situation was handled. Commit c8478a78c165c9d7727bbd0f8ac3cc4820dd9b5c just adds an explicit hit in the error message.

etingof avatar Jan 10 '19 17:01 etingof

Hi Ilya, I want to use --v2c-arch, because I do not need (want) to enable SNMPv3 and want to use the notification module for sending v2 traps? Is this possible?

Mirro888 avatar Jan 12 '19 21:01 Mirro888

@Mirro888 Not with the current notification module. It's possible to create another implementation based purely on the low-level SNMPv2c calls. But what is the motivation behind your desire to keep SNMPv3 disabled?

etingof avatar Jan 12 '19 21:01 etingof

Hi Ilya, I follow the advice about disabling SNMPv3 at http://snmplabs.com/snmpsim/tips-and-tricks.html, section "Faster response" :-). Moreover, I do not need SNMPv3 in my test lab. But it's good to know how to fix the issue. I will remove --v2c-arch and check the load on the server. Thanks.

Mirro888 avatar Jan 12 '19 22:01 Mirro888

I also want to use --v2c-arch, because I also do not need SNMPv3 and want to use the notification module for sending v2 traps only.

remco-dg avatar Jan 14 '19 10:01 remco-dg

@remco-dg Is variations module required only while sending notifications ? I'm trying to get some more details on the variations module , can't find much documentation on the same. Please advise

tkekan avatar Oct 15 '20 07:10 tkekan

@tkekan: The snmplabs.com website seems to be down. However, in the source tree here on https://github.com/etingof/snmpsim/blob/master/docs/source/documentation/simulation-with-variation-modules.rst you can find the documentation for the variation modules.

remco-dg avatar Oct 15 '20 09:10 remco-dg