[SNMP4J] How to write to a SNMP table?
Stefan Sanner
gemoron at hotmail.de
Fri Feb 28 08:25:03 CET 2014
Hello,
I work on a programm designed to manage the MAC-adresses which are whitelisted in a router.
I managed to read values from the test device and I can write scalar values, but I can't get programm to write new rows into the table.
I searched in the mail archive for a sollution and I found http://s16675406.onlinehome-server.info/pipermail/snmp4j/2012-January/004759.html .
I tried to get it working with TableUtils.createRow, but I couldn't make it by now.
-> What is meant with OID rowIndex?
-> Does anyone have an example on how to use the function?
This is the description of the table I need to modify http://system-update.eu/snmp_manager/brickmib_9_1/tables/wlanACLTable.html
And here is the code I try to use. this is the version to modify scalar values
Global variables:
String adress
Snmp snmp
public String executeSetRequest (String AccessName, String AccessPassword, String oid, String mac) throws IOException
{
snmp.getUSM().addUser(new OctetString(AccessName), new UsmUser(new OctetString(AccessName),AuthMD5.ID, new OctetString(AccessPassword),PrivDES.ID, new OctetString(AccessPassword)));
ScopedPDU pdu = new ScopedPDU();
pdu.setType(ScopedPDU.SET);
pdu.add(new VariableBinding(new OID(oid), new OctetString(mac)));
ResponseEvent response = snmp.send(pdu, getUserTarget(AccessName));
if(response == null)
throw new RuntimeException("GET timed out");
return response.getResponse().get(0).toString();
}
private UserTarget getUserTarget(String AccessName)
{
UserTarget target = new UserTarget();
target.setAddress(GenericAddress.parse(address));
target.setRetries(1);
target.setTimeout(3000);
target.setVersion(SnmpConstants.version3);
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
target.setSecurityName(new OctetString(AccessName));
return target;
}
I asked this question on StackOverflow as well http://stackoverflow.com/questions/22015185/how-to-add-rows-to-a-mib-table-in-snmp4j
More information about the SNMP4J
mailing list