Module: Net::SNMP::MIB

Defined in:
lib/net/snmp/mib/mib.rb,
lib/net/snmp/mib/node.rb,
lib/net/snmp/mib/templates.rb

Defined Under Namespace

Modules: Templates Classes: Node

Class Method Summary collapse

Class Method Details

.[](oid) ⇒ Object

Get an OID object representing the MIB node containing ‘oid`

  • ‘oid` argument may be a numerical oid, or the MIB name



26
27
28
# File 'lib/net/snmp/mib/mib.rb', line 26

def self.[](oid)
  Node.get_node(oid)
end

.add_mibdir(dirname) ⇒ Object

Add the specified directory to the path of locations which are searched for files containing MIB modules. Note that this does not actually load the MIB modules located in that directory



45
46
47
# File 'lib/net/snmp/mib/mib.rb', line 45

def self.add_mibdir(dirname)
  Wrapper.add_mibdir(dirname)
end

.get_node(oid) ⇒ Object

Get an OID object representing the MIB node containing ‘oid`

  • ‘oid` argument may be a numerical oid, or the MIB name



20
21
22
# File 'lib/net/snmp/mib/mib.rb', line 20

def self.get_node(oid)
  Node.get_node(oid)
end

.initObject

Configures the MIB directory search path (using add_mibdir ), sets up the internal MIB framework, and then loads the appropriate MIB modules (using netsnmp_read_module and read_mib). It should be called before any other routine that manipulates or accesses the MIB tree (but after any additional add_mibdir calls).



9
10
11
# File 'lib/net/snmp/mib/mib.rb', line 9

def self.init
  Wrapper.netsnmp_init_mib
end

.read_all_mibsObject

Read in all the MIB modules found on the MIB directory search list



14
15
16
# File 'lib/net/snmp/mib/mib.rb', line 14

def self.read_all_mibs
  Wrapper.read_all_mibs
end

.read_mib(filename) ⇒ Object

Similar to read_module, but takes the name of the file containing the MIB module. Note that this file need not be located within the MIB directory search list (although any modules listed in the IMPORTS clause do).



61
62
63
# File 'lib/net/snmp/mib/mib.rb', line 61

def self.read_mib(filename)
  Wrapper.read_mib(filename)
end

.read_module(name) ⇒ Object

Takes the name of a MIB module (which need not be the same as the name of the file that contains the module), locates this within the configured list of MIB directories, and loads the definitions from the module into the active MIB tree. It also loads any MIB modules listed in the IMPORTS clause of this module.



54
55
56
# File 'lib/net/snmp/mib/mib.rb', line 54

def self.read_module(name)
  Wrapper.netsnmp_read_module(name)
end

.translate(oid) ⇒ Object

Translates a numerical oid to it’s MIB name, or a name to numerical oid



31
32
33
34
35
36
37
38
39
40
# File 'lib/net/snmp/mib/mib.rb', line 31

def self.translate(oid)
  node = Node.get_node(oid)
  if oid =~ /^[0-9.]*$/
    # Node label + instance indexes from argument
    "#{node.label}#{oid.sub(node.oid.to_s, "")}"
  else
    # Node OID + instance indexes from argument
    "#{node.oid.to_s}#{oid.sub(node.label.to_s, "")}"
  end
end