如何使用snmp4j和社區字符串索引做snmpwalk?snmp4j snmpwalk與社區字符串索引
我可以通過改變社會的字符串,例如公共@ 123 (123是VLANID)
做一個共用字符串索引但這僅適用於SNMPGET !! ??:
public ResponseEvent get(OID oids) throws IOException {
PDU pdu = new PDU();
pdu.add(new VariableBinding(oid));
pdu.setType(PDU.GETNEXT);
ResponseEvent event = snmp.send(pdu, getTarget(), null);
}
private Target getTarget() {
Address targetAddress = GenericAddress.parse(sw.getAddress());
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(communityString));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version2c);
return target;
}
但當我嘗試做一個snmpwalk的這樣,我收到了超時
public HashMap<String, String> snmpWalk(String strOid) throws IOException {
OID oid = new OID(strOid);
TreeUtils treeUtils = new TreeUtils(snmp, new DefaultPDUFactory());
HashMap<String, String> snmpResult = new HashMap<String, String>();
List<TreeEvent> events = treeUtils.getSubtree(getTarget(), oid);
// some more code ...
}