[SNMP4J] SNMP Set operation
vasanth
vasanthu.ala at gmail.com
Thu Sep 19 07:08:17 CEST 2013
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
More information about the SNMP4J
mailing list