swisscom/ruby-netsnmp

Reading Gauge32 type OID returns nil

Closed this issue · 6 comments

Trying to read a Gauge32 type of OID:

snmpwalk -c public -v1 10.81.35.130 .1.3.6.1.2.1.17.7.1.4.5.1.1.1
SNMPv2-SMI::mib-2.17.7.1.4.5.1.1.1 = Gauge32: 805

When using the following code:

require 'netsnmp'

manager = NETSNMP::Client.new(host: "10.81.35.130", port: 161, community: "public",
                              timeout: 30, version: "1")

value = manager.get(oid: ".1.3.6.1.2.1.17.7.1.4.5.1.1.1")
puts "Value: [#{value}]"
puts value.inspect

manager.close

I get:

$ ruby test2.rb
Value: []
nil

https://github.com/swisscom/ruby-netsnmp/blob/master/lib/netsnmp/varbind.rb#L104

Long story short, this lib didn't ship with support for all aplication types, and those will return nil. Can you add a PR for gauge support?

@HoneyryderChuck Thanks for the feedback I'll look at that over the ween-end.

No worries. For the record, I didn't interact with all kinds of application values, and I left them empty so people could contribute with their findings. You just have to figure out how to unpack it.

To what I can see in the net-snmp2 library the Gauge32 data type is the same as a TimerTick:

https://github.com/jbreeden/net-snmp2/blob/2867d4ff5f04e2dcd08e791ac2f45d3b9ce83659/lib/net/snmp/varbind.rb#L33

So I'll give that a try.