comtarget.setCommunity(new OctetString(community));
comtarget.setVersion(SnmpConstants.version1);
comtarget.setAddress(targetaddress);
comtarget.setRetries(2);
comtarget.setTimeout(5000);
PDU pdu = new PDU();
ResponseEvent response;
Snmp snmp;
pdu.add(new VariableBinding(new OID(oid)));
pdu.setType(PDU.GET);
snmp = new Snmp(transport);
response = snmp.get(pdu,comtarget);
if(response != null) {
String errorStatus =
response.getResponse().getErrorStatusText();
if(errorStatus.equalsIgnoreCase("Success")) {
PDU pduresponse = response.getResponse();
String str =
pduresponse.getVariableBindings().firstElement().toString();
if(str.contains("=")) {
int len = str.indexOf("=");
str=str.substring(len+1, str.length());
}
str = str.trim();