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.

SNMP::Manager.open(:host => @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 =
manager.get_value(“1.3.6.1.4.1.164.6.2.34.1.0”).to_s.chomp
@setssh = manager.get_value(“1.3.6.1.4.1.164.6.2.34.4.0”).to_s.chomp

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


I get output like this:

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

ssh and telnet set to all on node 10.1.1.3
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: http://snmplib.rubyforge.org/doc/SNMP/PDU.html 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