What's the meaning of "SmiObject" in SNMP4J?

In IF-MIB, I use smiManager.findSmiObject(new OID(“”)) will get null, and I can use the oid to get the SmiObject. So how can I judge whether an oid isn a SmiObject or not?
If it is not an SmiObject, how can I get the description from the oid?

SmiObject in SNMP4J-SMI-PRO can be any SMI OBJECT definition of a MIB specification.
A SmiObject has always an object identifier, but instances of such “object types” in an agent must start with the corresponding OID of the SmiObject but can have additional “index” sub-identifiers as suffix.

I am not sure what your question is, but maybe you would like tom identify the SmiObject for an instance OID, right?

That can be done with something like that:

OID oidInstance = new OID("");
SmiObject smiObject = null; 
while ((oidInstance.length() > 0) && ((smiObject = smiManager.findSmiObject(oidInstance)) == null)) {
    oidInstance = oidInstance.trim();
if (smiObject != null) {
    // do something with the SmiObject

I am going to add an additional findSmiObjectType method to the SmiManager that will use a faster (for long index sub-IDs) mechanism than the above to lookup the SmiObjectType for an instance object identifier OID.

Does that help?

I want to get all the oid and its name nad its description. For example,if the mid have 100 oids ,the result will get 100 descriptions.I know the walk command in Net-SNMP,but I do not how to do this in SNMP4J-SMI-PRO.

Ok, that is easy:

List<String> moduleNames = SmiManager.getLoadedModuleNames();
for (String moduleName : moduleNames) {
    SmiModule smiModule = SmiManager.findSmiModule(moduleName);
    Collection<OID> oids = smiModule.getObjectIdentifiers(OIDComparator.OIDOrder.depthFirstOrder);
    for (OID oid : oids) {
        SmiObject smiObject = smiManager.findSmiObject(oid);
1 Like

Thank you,I have solve the problem according to your demo.

The result is incomplete.I can not get the oid from the code such as the oid exists.

Have you loaded the SNMPv2-MIB?

The following unit test works for me:

public void testFindSmiObjectSystem() {
    SmiObject smiObject = smiManager.findSmiObject("SNMPv2-MIB", "system");
    assertEquals(SmiType.OBJECT_NAME, smiObject.getType());
    assertEquals("system", smiObject.getObjectName());
    assertEquals("", smiObject.getOID().toDottedString());