snmpsim icon indicating copy to clipboard operation
snmpsim copied to clipboard

snmpsimd.py: Value evaluation error for subprocess and hexlified values

Open pieterheydenrych opened this issue 6 years ago • 1 comments

I encounter a value evaluation error when using the subprocess variation module to update hexlified values in .snmprec files.

I'm using HOST-RESOURCES-MIB::hrSystemDate for illustration with the use case to return the current timestamp whenever polled. The value is a RFC2579 DateAndTime octet string.

Raw capture:

1.3.6.1.2.1.25.1.2.1|4x|07e30307001b01152b0000

snmpwalk result using the default raw capture:

HOST-RESOURCES-MIB::hrSystemDate.1 = STRING: 2019-3-7,0:27:1.21,+0:0

I now update the snmprec to use subprocess to provide the octetstring. snmpsimd logs the following error:

ERROR data error at /home/someuser/pydev/snmpsim/data/snmpwalk/host.snmprec controller for 1.3.6.1.2.1.25.1.2: value evaluation error for tag '4', value b'07e30307001b01152b0000\n'

The issue remains no matter which approach I use e.g.

1.3.6.1.2.1.25.1.2.1|4x:subprocess|get_date.py  <=== this is the desired approach
1.3.6.1.2.1.25.1.2.1|4x:subprocess|echo 07e30307001b01152b0000
1.3.6.1.2.1.25.1.2.1|4:subprocess|echo hexvalue=07e30307001b01152b0000

The last example doesn't result in an error, but it ends up passing a hexflified value for the whole 'hexvalue=07e30307001b01152b0000' string which doesn't produce the desired outcome. I don't believe hexvalue is supported for subprocess as it's not mentioned in the docs.

I can reproduce the issue on versions 0.4.6 and 0.4.7 on RHEL Python 3.6/3.7.

UPDATED: It works when running snmpsim on Python 2.7. Is there anything to be done to help it along in Python 3?

Thanks! Pieter

pieterheydenrych avatar Mar 07 '19 01:03 pieterheydenrych

Thank you for raising this and sorry for it takes time!

There is a fix in the release candidate as well as in master to address this problem.

etingof avatar Apr 12 '19 06:04 etingof