2

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

bee81
  • 35
  • 1
  • 7

2 Answers2

4

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

selectAll
  • 7
  • 2
Kevin Bayes
  • 846
  • 11
  • 17
-1

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();
Balwinder SIngh
  • 1,831
  • 2
  • 24
  • 28
  • MOTableBuilder is not part of SNMP4J-Agent. The example does not define the mandatory MOTableIndex for the table. – ooSNMP Dec 04 '19 at 00:44