0

I am using SNMP4J Framework and it implements and makes possible the standard SET, GET, GET-NEXT, etc. messages.

For example, with a SET, I can update the value of the MIB OID "1.3.6.1.2.50.0". This works perfectly for me. I can do that using org.snmp4j.Snmp.set(PDU pdu, Target target)

What I want to do now is to CREATE a custom MIB OID (as "1.3.6.1.2.100.0") FROM the client and assign a value to it and not simply update an existing MIB OID value.

Is there any standard SNMP way to do that easily ?

rBenks93
  • 53
  • 1
  • 8

1 Answers1

1

Yes.

But it doesn't make sense in the context of SNMP to "create" a new scalar out of thin air; normally you are setting one already defined with a pre-defined OID, and that OID will usually be shared agent -> manager via a MIB file. Its OID will be the 0th instance (e.g., sysDescr.0).

You can however add/remove rows in a SNMP table (its rows and cells will have OIDs at instance 1, instance 2, etc.); and that SNMP table may have zero rows. The cells in the table can have values.

Here is some background info on SNMP tables.

k1eran
  • 4,492
  • 8
  • 50
  • 73
  • Thank you for your answer @k1eran. Do you think it is possible to append a custom OID (determined by the manager) in an SNMP table ? For example, the table will be at OID "1.3.6.1.2.1" and I want to append an IP address to this OID "1.3.6.1.2.1.vvv.xxx.yyy.zzz", then increment a statistic linked to this IP address in another column of the row. – rBenks93 Oct 27 '15 at 14:50
  • 1
    Yes, you can define a table where its rows have index of type = IpAddress (see https://tools.ietf.org/html/rfc1155) and other columns with whatever data, e.g. statistics, that you need. – k1eran Oct 28 '15 at 00:36
  • Do you have an idea which method can I use to add a row to the table ? I'm trying with PDU.addAll(VariableBinding[] vbs) but it doesn't work. – rBenks93 Oct 28 '15 at 16:19
  • Look at MOTable http://www.snmp4j.org/agent/doc/org/snmp4j/agent/mo/MOTable.html Also look at examples at http://www.jayway.com/2010/05/21/introduction-to-snmp4j/ – k1eran Oct 29 '15 at 17:52
  • Yes, I've looked. But I still can't see the link between the PDU.add method (which we always use from the client to make a SET) and the methods that add rows in the agent. Any help about making that link will be appreciated. Thanks – rBenks93 Oct 30 '15 at 14:01
  • 1
    _"its rows and cells will have OIDs at instance 0, instance 1, etc"_ Although valid, recommended best practice is to avoid that - have your table indexes start at 1 to avoid confusion. See §7.7 in RFC 2578. – Lightness Races in Orbit Oct 17 '17 at 22:28
  • @LightnessRacesinOrbit Thank you, good point. Answer updated. – k1eran Oct 23 '17 at 10:16