|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.outbackinc.services.protocol.snmp.mib.SimpleMIBDictionary
A basic implementation of a SnmpMIBDictionary. SimpleMIBDictionary takes either a simple file-based mib format (.jmib) or MIB file (IF-MIB.my), and maintains an in-memory dictionary of mib names, OIDs, descriptions, types, access, status, and enumeration values. Users may resolve names to OIDs (& vice-versa), get description, type, access, and status strings from OIDs and names, as well as lookup the integer and string values associated with enumerations.
Usage: The following code snippet provides an example of its use:
// Create the service SnmpMIBService cSnmpMIBService = SnmpLocalInterfaces.getMIBService(); // Load the IF-MIB MIB file into the service InputStream cInputStream = jMIBC.loadMib("IF-MIB.my"); cSnmpMIBService.loadMIB("IF-MIB", cInputStream); // Or alternately, load the IF-MIB jMIB file into the service //cSnmpMIBService.loadMIB("IF-MIB", new FileInputStream("IF-MIB.jmib")); // Get a handle to the mib dictionary for the MIB SnmpMIBDictionary cSnmpMIBDictionary = service.getMIBDictionary("IF-MIB"); // Resolve name to OID (will return 1.3.6.1.2.1.2.2.1.10): String szOid = cSnmpMIBDictionary.resolveName("ifInOctets"); // Resolve name to OID (will return 1.3.6.1.2.1.2.2.1.10.1): szOid = cSnmpMIBDictionary.resolveName("ifInOctets.1"); // Resolve OID to name (will return ifInOctets): String szName = cSnmpMIBDictionary.resolveOID("1.3.6.1.2.1.2.2.1.10"); // Resolve OID to name (will return ifInOctets.1): szName = cSnmpMIBDictionary.resolveOID("1.3.6.1.2.1.2.2.1.10.1"); // Resolve name to name description (will return "The total number ...") String szDescription = cSnmpMIBDictionary.resolveNameDescription("ifInOctets"); // Resolve OID to OID description (will return "The total number ...") szDescription = cSnmpMIBDictionary.resolveOIDDescription("1.3.6.1.2.1.2.2.1.10"); // Resolve name to name type (will return "Counter") String szType = cSnmpMIBDictionary.resolveNameType("ifInOctets"); // Resolve OID to OID type (will return "Counter") szType = cSnmpMIBDictionary.resolveOIDType("1.3.6.1.2.1.2.2.1.10"); // Resolve name to name access (will return "read-only") String szAccess = cSnmpMIBDictionary.resolveNameAccess("ifInOctets"); // Resolve OID to OID access (will return "read-only") szAccess = cSnmpMIBDictionary.resolveOIDAccess("1.3.6.1.2.1.2.2.1.10"); // Resolve name to name status (will return "mandatory") String szStatus = cSnmpMIBDictionary.resolveNameStatus("ifInOctets"); // Resolve OID to OID status (will return "mandatory") szStatus = cSnmpMIBDictionary.resolveOIDStatus("1.3.6.1.2.1.2.2.1.10"); // Find enum string for enum int value (will return ethernetCsmacd): String szEnum = cSnmpMIBDictionary.resolveEnum("ifType", 6); // Find enum int for enum string value (wil return 6): int iEnum = cSnmpMIBDictionary.resolveEnumDisplayString("ifType", "ethernetCsmacd");
Constructor Summary | |
SimpleMIBDictionary(java.lang.String szMibName,
java.io.InputStream cInputStream)
Create a new MIB dictionary based upon formatted input. |
Method Summary | |
java.lang.String |
getMIBDictionaryName()
Get the name of the MIB Dictionary object. |
java.lang.String |
resolveEnum(java.lang.String szName,
int iValue)
Resolve an enumerated value (as an integer) to the corresponding displayable name. |
int |
resolveEnumDisplayString(java.lang.String szName,
java.lang.String szValue)
Get the numeric value of a given string of an enumerated type. |
java.lang.String |
resolveName(java.lang.String szName)
Find the Object ID for a given object name. |
java.lang.String |
resolveNameAbstractType(java.lang.String szName)
Find the 'abstract' type for a given object name. |
java.lang.String |
resolveNameAccess(java.lang.String szName)
Find the access for a given object name. |
java.lang.String |
resolveNameDescription(java.lang.String szName)
Find the description for a given object name. |
java.lang.String |
resolveNameStatus(java.lang.String szName)
Find the status for a given object name. |
java.lang.String |
resolveNameType(java.lang.String szName)
Find the type for a given object name. |
java.lang.String |
resolveOID(java.lang.String szOid)
Resolve an Object ID to its corresponding name. |
java.lang.String |
resolveOIDAbstractType(java.lang.String szOid)
Resolve an Object ID to its corresponding 'abstract' type. |
java.lang.String |
resolveOIDAccess(java.lang.String szOid)
Resolve an Object ID to its corresponding access. |
java.lang.String |
resolveOIDDescription(java.lang.String szOid)
Resolve an Object ID to its corresponding description. |
java.lang.String |
resolveOIDStatus(java.lang.String szOid)
Resolve an Object ID to its corresponding status. |
java.lang.String |
resolveOIDType(java.lang.String szOid)
Resolve an Object ID to its corresponding type. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimpleMIBDictionary(java.lang.String szMibName, java.io.InputStream cInputStream)
szMibName
- The name to assign to the mibcInputStream
- An input stream used to read in the raw
mib definition The raw InputStream mib import one key/value mapping per line. The mappings are in the form 'key=value'. Valid keys can be object names, OIDs, and 'objectname.attribute' entries.
The following snippet provides an example:
sysDescr=1.3.6.1.2.1.1.1 sysDescr.TYPE=OctetString sysDescr.ABSTRACTTYPE=DisplayString sysDescr.ACCESS=read-only sysDescr.STATUS=mandatory sysDescr.DESCRIPTION=A textual description of the entity. This value should include the full name and version identification of the system's hardware type, software operating-system, and networking software. It is mandatory that this only contain printable ASCII characters. ifType=1.3.6.1.2.1.2.2.1.3 ifType.TYPE=Enum ifType.ABSTRACTTYPE=INTEGER ifType.ACCESS=read-only ifType.STATUS=mandatory ifType.DESCRIPTION=The type of interface, distinguished according to the physical/link protocol(s) immediately `below' the network layer in the protocol stack. ifType.other=1 ifType.1=other ifType.regular1822=2 ifType.2=regular1822 ifType.hdh1822=3 ifType.3=hdh1822 ifType.ddn-x25=4 ifType.4=ddn-x25Normally, the InputStream is is derived from a MIB using the com.outbackinc.services.protocol.snmp.mib.jMIBC.loadMib() method.
The following code snippet provides an example:
SimpleMIBDictionary cSimpleMIBDictionary = null; try { InputStream istream = jMIBC.loadMib("HOST-RESOURCES-MIB.my"); cSimpleMIBDictionary = new SimpleMIBDictionary("HOST-RESOURCES-MIB", istream); } catch( Exception e ) { System.out.println("Couldn't load the HOST-RESOURCES-MIB MIB ... " + e.getMessage() + ".\n"); }Alternately, .jmib files (constructed by jSNMP Enterprises' MIB compiler jMIBC or from the Extended MOSY output generated by a MIB complier such as SMICng) may be used for the InputStream.
The following code snippet provides an example:
SimpleMIBDictionary cSimpleMIBDictionary = null; try { cSimpleMIBDictionary = new SimpleMIBDictionary("rfc2233", new FileInputStream("rfc2233.jmib")); } catch( Exception e ) { System.out.println("Couldn't load the HOST-RESOURCES-MIB MIB ... " + e.getMessage() + ".\n"); }
Method Detail |
public java.lang.String getMIBDictionaryName()
SnmpMIBDictionary
getMIBDictionaryName
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
public java.lang.String resolveName(java.lang.String szName)
SnmpMIBDictionary
resolveName
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOID(java.lang.String szOid)
SnmpMIBDictionary
resolveOID
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveNameDescription(java.lang.String szName)
SnmpMIBDictionary
resolveNameDescription
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOIDDescription(java.lang.String szOid)
SnmpMIBDictionary
resolveOIDDescription
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveNameType(java.lang.String szName)
SnmpMIBDictionary
resolveNameType
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOIDType(java.lang.String szOid)
SnmpMIBDictionary
resolveOIDType
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveNameAbstractType(java.lang.String szName)
SnmpMIBDictionary
resolveNameAbstractType
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOIDAbstractType(java.lang.String szOid)
SnmpMIBDictionary
resolveOIDAbstractType
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveNameAccess(java.lang.String szName)
SnmpMIBDictionary
resolveNameAccess
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOIDAccess(java.lang.String szOid)
SnmpMIBDictionary
resolveOIDAccess
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveNameStatus(java.lang.String szName)
SnmpMIBDictionary
resolveNameStatus
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- Object name to resolve to its OIDpublic java.lang.String resolveOIDStatus(java.lang.String szOid)
SnmpMIBDictionary
resolveOIDStatus
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szOid
- Object ID to resolvepublic java.lang.String resolveEnum(java.lang.String szName, int iValue)
SnmpMIBDictionary
resolveEnum
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- object name (or OID)iValue
- current (integer) valuepublic int resolveEnumDisplayString(java.lang.String szName, java.lang.String szValue)
SnmpMIBDictionary
resolveEnumDisplayString
in interface SnmpMIBDictionary
com.outbackinc.services.protocol.snmp.mib.SnmpMIBDictionary
szName
- object name (or OID)szValue
- displayable string value for the object
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Home Services Products Purchase Contact Us About Us Legal Ceramics
Copyright © 2003-2008 jSNMP Enterprises All rights reserved.