2
votes

I am using the python to send an snmpset message to an snmp agent. I have the correct OID as I can use it to get data with snmpget. However, it will not set the data. I am sending octets in hex format (two hex values) separated by a colon. I might have to put apostrophes around it, right? Here is the example of the line I am sending

foo = os.popen("snmpset -v 2c -c private 192.1.55.222 .1.2.6.5.4.1.24022.4.27.1.6.4.4 x 00:00:04:cf:00:00:00:00:00:00")

as you can see, I am sending an Octet string with type x.

Can anyone hazard a guess as to how I should pass in the set value of "00:00:04:cf:00:00:00:00:00:00". I know the setvalue is of the right length and type because I have used it in a MIB browser.

1
Is the foo = os.popen... an actual code copied from your program? I can't imagine how this can work, not from the SNMP (I know nothing about it), but from the Python point of view. Can you clarify what kind of error (or other problem) you are getting. - Helgi
Hey Helgi, This is actual code, but I can see there are errors: I am passing in a string. Let me edit. That syntax is correct as this code is used to successfully set other atributes. It is just this long hex string that is not working. - user442920

1 Answers

0
votes

A couple of things:

1) there is a native python interface you could use instead of calling a system command. There are in fact multiple choices, including pysnmp (done in python) and Net-SNMP's python module (done in C).

2) The Net-SNMP snmpset command expects straight hex code without any :s in it. So if you remove the :s you may find it'll work.