[SNMP4J] SNMP Set operation

Frank Fock fock at agentpp.com
Thu Sep 19 08:27:27 CEST 2013


Hi,

You simply forgot to add the vb to the pdu.

Best regards,
Frank

Am 19.09.2013 07:08, schrieb vasanth:
> Hi,
>
>
> I want to set the sysLocation of the device using SNMP4J. Could you please
> help me to do it. is there any sample program available?
>
> I found the below code from internet but its always replacing the
> sysLocation as Empty ("")
>
> String oid = handlerProperties.getProperty(OID_PARAM_NAME, DEFAULT_OID);
> String value = handlerProperties.getProperty(OID_VALUE_PARAM_NAME,
> DEFAULT_VALUE);
>
> String subject =
> handlerProperties.getProperty(InventoryProperties.DEVICE_ID);
>          SNMPRequestParameters transParams = getParams(subject,
> handlerContext.getHandlerInventory(),handlerProperties);
>
> Target setTarget = transport.buildTargetFromParams(transParams);
> if(setTarget instanceof CommunityTarget) {
> CommunityTarget target = (CommunityTarget)setTarget;
> target.setCommunity(new OctetString(transParams.getWriteCommunity()));
> }
> PDUFactory pduFactory = new
> PalPDUFactory(transParams.getContextName(),PDU.SET);
> PDU setPDU = pduFactory.createPDU(setTarget);
>   OctetString os = new OctetString(value);
> VariableBinding vb = new VariableBinding(new OID(oid),os);
>
> carrier = transport.getCarrier(params);
>              ResponseEvent response = carrier.sendPDU(target, requestPDU);
>
> Thanks,
> Vasanth
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/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