oid,网上都查遍了,就是什么都拿不到,那位做过,说说是怎么回事啊。
String[] returnValueString = null; // oid走访结果数组

SNMPv1CommunicationInterface comInterface = null;
try {
InetAddress hostAddress = InetAddress.getByName(ipAddress);

comInterface = new SNMPv1CommunicationInterface(
version, hostAddress, community);
comInterface.setSocketTimeout(2000);

// 返回所有以oid开始的管理信息库变量值
SNMPVarBindList tableVars = comInterface.retrieveMIBTable(oid);
returnValueString = new String[tableVars.size()];

// 循环处理所有以oid开始的节点的返回值
for (int i = 0; i < tableVars.size(); i++) {
SNMPSequence pair = (SNMPSequence) tableVars.getSNMPObjectAt(i); // 获取SNMP序列对象, 即(OID,value)对
SNMPObject snmpValue = pair.getSNMPObjectAt(1); // 获取某个节点的返回值
String typeString = snmpValue.getClass().getName(); // 获取SNMP值类型名
// 设置返回值
if (typeString.equals("snmp.SNMPOctetString")) {
String snmpString = snmpValue.toString();
int nullLocation = snmpString.indexOf('\0');
if (nullLocation >= 0)
snmpString = snmpString.substring(0, nullLocation);
returnValueString[i] = snmpString;
} else {
returnValueString[i] = snmpValue.toString();
}
}
} catch (SocketTimeoutException ste) {
if (log.isErrorEnabled()) {
log.error("走访IP为" + ipAddress + ", OID为" + oid + " 时超时!");
}
returnValueString = null;
} catch (Exception e) {
throw new AppException("SNMP走访节点时发生错误!", e);
} finally {
if (comInterface != null) {
try {
comInterface.closeConnection();
} catch (SocketException e) {
comInterface = null;
}
}
}

return returnValueString;