SNMP Set response yields inconsistent data

I’m working on some code and need some help with converting an SNMP Set
response into something that makes sense and is consistent from each set
action… Basically my code reads a file of ip addresses, queries a
bunch of snmp values, and if certain conditions are met it sets an OID
to a new value.

The interesting parts of my code are below. Any help is appreciated!
The manager gets and sets work, but I’d like to work in some error
correction so if something fails or doesn’t respond like I’d expect it
to, to throw an error. => @ipAddress, :community => readwrite,
:version => :SNMPv1, :retries => 2, :timeout => 3) do |manager|
@sysObjId = manager.get_value(“sysObjectID.0”).to_str.chomp
@sysName = manager.get_value(“sysName.0”).to_s.chomp
@upTime = manager.get_value(“sysUpTime.0”).to_s.chomp
@hwVer = manager.get_value(“sysDescr.0”).to_s.chomp
@settelnet =
@setssh = manager.get_value(“”).to_s.chomp

case sysObjId
if settelnet == “3” && setssh == “3”
puts “ssh and telnet set to all on node #{ipAddress}”
varbindtt =“”,
@setresp = manager.set(varbindtt).to_s.chomp
puts “the response is: #{setresp}”

I get output like this:

ssh and telnet set to all on node
the response is: #SNMP::Response:0x000000073e7838

ssh and telnet set to all on node
the response is: #SNMP::Response:0x00000007211860

The interesting part is BOTH set commands were successful, and BOTH
devices are the same vendor and type. If they were different “lines” I
could accept that each response would be different. How can I decode
this response to a “success” or “fail”? I realize I could just query
the device again for the OID’s status, but since the response is coming
back anyways, why not make it efficient? I believe the answer lies
somewhere here: but I
can’t decipher what’s supposed to happen!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs