[SNMP4J] How to write to a SNMP table?

Frank Fock fock at agentpp.com
Fri Feb 28 08:47:36 CET 2014


Hi,

As the Javadoc of TableUtils.createRow explains, this method can only be 
used with
tables that have a RowStatus column. Since your table does not have such 
a column,
it will not work with such a table.

The rowIndex is the OID suffix that identifies the table row. In your 
case it is
the MacAddress + IfIndex encoded as an OID.

Best regards,
Frank

Am 28.02.2014 08:25, schrieb Stefan Sanner:
> 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
>   		 	   		   		 	   		
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://s16675406.onlinehome-server.info/mailman/listinfo/snmp4j

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231




More information about the SNMP4J mailing list