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
-
.[](oid) ⇒ Object
Get an OID object representing the MIB node containing ‘oid` - `oid` argument may be a numerical oid, or the MIB name.
-
.add_mibdir(dirname) ⇒ Object
Add the specified directory to the path of locations which are searched for files containing MIB modules.
-
.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.
-
.init ⇒ Object
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).
-
.read_all_mibs ⇒ Object
Read in all the MIB modules found on the MIB directory search list.
-
.read_mib(filename) ⇒ Object
Similar to read_module, but takes the name of the file containing the MIB module.
-
.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.
-
.translate(oid) ⇒ Object
Translates a numerical oid to it’s MIB name, or a name to numerical oid.
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
46 47 48 |
# File 'lib/net/snmp/mib/mib.rb', line 46 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 |
.init ⇒ Object
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_mibs ⇒ Object
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).
62 63 64 |
# File 'lib/net/snmp/mib/mib.rb', line 62 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.
55 56 57 |
# File 'lib/net/snmp/mib/mib.rb', line 55 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 41 |
# 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 # (Regex ensures the module qualifier is also removed, if present) "#{node.oid.to_s}#{oid.sub(%r[.*#{node.label.to_s}], "")}" end end |