Skip to content
jbreeden edited this page Nov 8, 2014 · 2 revisions

By default, net-snmp loads all of your system MIBS when you call Net::SNMP.init. You can add additional mibs by adding them to your MIBS environment variable. You can also explicitly add MIBs using the MIB api. For example:

require 'net-snmp2'
Net::SNMP.init
Net::SNMP::MIB.add_mibdir("/usr/local/share/mibs")
Net::SNMP::MIB.read_mib("RFC1213-MIB.txt")

Having the appropriate MIBs loaded will allow you to pass names instead of numeric oids to net-snmp methods. You can also pass Net::SNMP::OID objects. For example:

oid = Net::SNMP::OID.new('sysDescr.0') # or Net::SNMP::OID.new("1.3.6.1.2.1.1.1.0")
puts oid.to_s  --> '1.3.6.1.2.1.1.1.0'
puts oid.label --> 'sysDescr.0'
pdu = session.get([oid])

Clone this wiki locally