Question

I am totally new to mib and i have read about snmp on techdive and get the basic understanding of SNMP4J can anyone tell me how to use MIB in snmp4j ? Thank in Advance

Was it helpful?

Solution

Sure. You basically query a client for information giving an OID for the field in the MIB you require.

A basic sample taken from the referenced blog is:

PDU request = new PDU();
request.setType(PDU.GET);
OID oid= new OID("1.3.6.1.2.1.1.1.0");
request.add(new VariableBinding(oid));

The reference you can use: http://www.jineshmathew.com/2012/11/how-to-get-started-with-snmp4j.html

Here is another reference: http://www.jayway.com/2010/05/21/introduction-to-snmp4j/

Here is the java doc for the OID: http://www.snmp4j.org/doc/org/snmp4j/smi/OID.html

OTHER TIPS

you need to register your MIB using snmp4j.

   final OID interfacesTable = new OID(".1.3.6.1.4.1.44.1");
        MOTableBuilder builder = new MOTableBuilder(interfacesTable)
        .addColumnType(SMIConstants.SYNTAX_OCTET_STRING,MOAccessImpl.ACCESS_READ_WRITE)
        //first row
        .addRowValue(new OctetString("loopback"))
        //next row
        .addRowValue(new Integer32(4));
        agent.registerManagedObject(builder.build());
        agent.listen();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top