[SNMP4J] Sending SNMPV3 Notifications Containing Table Row

Peter S peterkt2000 at yahoo.com
Fri Apr 1 20:11:02 CEST 2016


Greetings,
Thank you for the SNMP4J library.
I understand with the SNMP protocol there is no concrete implementation of a Table or Row. These concepts are part of the SMI specification, not the protocol.

However, I was wondering if the SNMP4J Agent API provided a convenience method or API for sending an entire row or even a table of rows in an SNMP trap or notification. I am using the free version of SNMP4J agent, version 2.4.2.  I have functioning code for sending simple scalar notifications. My question concerns sending complex types, like table rows. If such a row can be containing in one UDP message, is there an easy way to just provide this row to the SNMP4J api. Something like the following:
MOTable<...> table = moFactory.createTable(rootTableOID, indexDef, columns)... build table and rowsScopedPDU pdu = new ScopedPDU()List<VariableBinding> vb = new ArrayList ...vb.add(0, new VariableBinding(SnmpConstants.sysUpTime, sysUpTime));vb.add(1, new VariableBinding(SnmpConstants.snmpTrapOID, notificationRoot));vb.add(2, new VariableBinding(tableRootOID, table);..orvb.add(2, new VariableBinding(tableRootOID, a row in table)...pdu.addAll(vb);
snmp.notify(pdu, target);


Alternatively ...

If there is no such support for this functionality, my approach is to simply add multiple VariableBinding instances for each column instance value to a ScopedPDU instance. Would this be something like the following?
ScopedPDU pdu = new ScopedPDU()List<VariableBinding> vb = new ArrayList ...vb.add(0, new VariableBinding(SnmpConstants.sysUpTime, sysUpTime));vb.add(1, new VariableBinding(SnmpConstants.snmpTrapOID, notificationRoot));
...for each column in a table rowvb.add(columnIndex, new VariableBinding(full columnOID, including instance number, value)pdu.addAll(vb);
snmp.notify(pdu, target);
Thank you in advance for your help!
-Peter




More information about the SNMP4J mailing list