smi-ffi

FFI wrapper around libsmi. Useful for translating SNMP oids and retreiving other MIB information. You should have libsmi installed, and a directory with any MIB files you want to use.

USAGE

# Set path to MIBs, initialize libsmi, and load the standard RFC1213 MIB Smi::Config.set_path(‘/usr/local/share/mibs’) Smi::Config.init(nil) # You MUST call this Smi::Config.load_module(“RFC1213-MIB”)

# get the oid for sysDescr Smi.translate(“sysDescr”) => “.1.3.6.1.2.1.2.1.1”

# get a MIB node node = Smi::Node.get_node(“ifIndex”) puts node.name # “ifIndex” puts node.oid # “1.3.6.1.2.1.2.2.1.1” puts node.description # “Some verbose description”

# get children of node node.children.each |child|

puts "#{child.name} - #{child.oid}"

end

# get a MIB module m = Smi::Module.get_module(“RFC1213-MIB”) node = m.get_nodes

You may have to add smilib to LD_LIBRARY_PATH. For example export LD_LIBRARY_PATH=/opt/local/lib

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 mixtli. See LICENSE for details.