Retrieving MIB Information

 

Manipulating OIDs

 

The MibModulelink to javadocs class enables operations on the loaded MIB modules. This class instance for a MIB module is obtained by loading the MIB through the MibOperationslink to javadocs object.

 

The translateToNames(String) method of the MibModule is used for translating numbered OID String to named OID String. The translateToNumbers(String) method is used for translating named OID String to numbered OID String. If the OID does not start with a dot, the standard prefix .1.3.6.1.2.1 is automatically appended and the OID String is returned.

 

The getInstanceString(SnmpOID) method of MibOperations class gets the instance component of the OID as a String. Instances of scalar objects are identified by the OID value of the object suffixed with ".0". Instances of columnar objects are identified by their OID values suffixed by their index components. The getInstanceString(SnmpOID, MibNode) method of MibOperations class avoids having to search for node if already available. However, it is not ensured that a null is returned for a mismatched node. This returns the sub-string corresponding to the instance. For example, if the MibNode is system and the OID as sysDescr, the return value starts with the sub-id of mib-2. The intersection of the node OID and the given OID are eliminated from the returned OID string.

 

The getNearestNode() method of MibModule class gets the nearest MIB node corresponding to the int array of the OID. The getNearestNode(SnmpOID) method of MibOperations class searches all MIB modules loaded in this MibOperations instance and returns the OID if found.

 

The getSubID() of the MibNodelink to javadocsclass gives the sub identifier of this node's object-identifier. The ObjectIdentifier have the 128 sub-identifiers, each sub-identifier can have the value ranges from 0 to 4294967295. The getNumberedOIDString() method of the MibNode class gives the numbered OID string of the node. The getOID() method of the MibNode class gives the numbered OID of the node as an int array. The getOIDString() method of the MibNode class gives the named OID of the node. The getOIDVector() method of the MibNode class gets the named OID of the node as a vector.

Processing MIB Information

 

The createVariableBinding(String varName, String[] indexes, String value) method of the MibOperations class creates an SnmpVarBind instance with the supplied parameters.

 

The method decodeInstanceString(String, Vector) of the LeafSyntax class decodes an instance string based on the instance and index nodes. The encodeInstanceString() method of the MibOperations class encodes an instance string based on the SNMP type of the index node. This encoded instance string should be concatenated to the node OID to get the complete OID. The encodeInstanceString() method of the LeafSyntax class encodes an instance string based on the index vector and index nodes.

 

The createSnmpVarBind(Vector, SnmpVar, Vector) method of the MibNode class creates an SnmpVarBind instance with the supplied parameters.

 

The method decodeDefval() of the MibNode class decodes the DEFVAL value that is defined for this node and returns the corresponding SnmpVar object.

 

Displaying MIB Information

 

To print the value in hex string format, you can use the toByteString() method. To print the values in the NVT ASCII format, the setIgnoreSpecificControlCodes(boolean) method of the MibOperations class can be to set true. If the value is between 32 and 127, the ASCII value is printed.



Copyright © 2012, ZOHO Corp. All Rights Reserved.