Class: SNMP::MIB

Class | SNMP::MIB
In: | lib/snmp/mib.rb
Parent: | Object

### Methods

import_module import_supported? list_imported load_module module_file_name new oid varbind varbind_list

### Classes and Modules

Class SNMP::MIB::ModuleNotLoadedError

### Constants

MODULE_EXT | = | 'yaml'

### Public Class methods

import_module(module_file, mib_dir=DEFAULT_MIB_PATH)

Import an SMIv2 MIB file for later loading. A module only needs to be installed once.

      module_file - the filename of the module to be imported
      mib_dir - the output directory for the serialized MIB data

NOTE: This implementation requires that the ‘smidump’ tool is available in the PATH. This tool can be obtained from the libsmi website at http://www.ibr.cs.tu-bs.de/projects/libsmi/ .

ALSO NOTE: The file format in future releases is subject to change. For now, it is a simple YAML hash with the MIB symbol as the key and the OID as the value. These files could be generated manually if ‘smidump’ is not available.

Here is an example of the contents of an output file:

      ---
      ipDefaultTTL: 1.3.6.1.2.1.4.2
      ipForwDatagrams: 1.3.6.1.2.1.4.6
      ipOutRequests: 1.3.6.1.2.1.4.10
      ipOutNoRoutes: 1.3.6.1.2.1.4.12
      ipReasmTimeout: 1.3.6.1.2.1.4.13
      icmpInDestUnreachs: 1.3.6.1.2.1.5.3

import_supported?()

The MIB.import_module method is only supported if the external ‘smidump’ tool is available. This method returns true if a known version of the tool is available.

list_imported(regex=//, mib_dir=DEFAULT_MIB_PATH)

Returns a list of MIB modules that have been imported. All of the current IETF MIBs should be available from the default MIB directory.

If a regex is provided, then the module names are matched against that pattern.

module_file_name(module_name, mib_dir=DEFAULT_MIB_PATH)

Returns the full filename of the imported MIB file for the given module name.

new()

### Public Instance methods

load_module(module_name, mib_dir=DEFAULT_MIB_PATH)

Loads a module into this MIB. The module must be imported before it can be loaded. See MIB.import_module .

oid(name)

Returns an ObjectId for the given name. Names are in the format <ModuleName>::<NodeName>.<Index> with ModuleName and Index being optional.

varbind(name, value=Null)

Returns a VarBind object for the given name and value. The name can be a String, ObjectId, or anything that responds to :to_varbind.

String names are in the format <ModuleName>::<NodeName>.<Index> with ModuleName and Index being optional.

varbind_list(object_list, option=:KeepValue)

Returns a VarBindList for the provided list of objects. If a string is provided it is interpretted as a symbolic OID.

This method accepts many different kinds of objects:

- single string object IDs e.g. "1.3.6.1" or "IF-MIB::ifTable.1.1"
- single ObjectId
- list of string object IDs
- list of ObjectIds
- list of VarBinds

[Validate]