0
我在管理器端收到「錯誤的版本或解碼錯誤」。我是 只是想知道下面的示例陷阱發送者代碼是否有缺失。「版本不正確或解碼錯誤」發送陷阱時
public class SampleTrapSender {
public static void main(String[] args) {
String address = "172.27.41.101";
String port = "162";
address = address + "/" + port;
System.out.println("Target adddress ...." + address);
try{
Snmp snmp = new Snmp(new
DefaultUdpTransportMapping());
PDU trap = new PDU();
trap.setType(PDU.TRAP);
OID oid = new OID("1.3.6.1.4.1.4976.2.1.1.0");
Variable var = new OctetString("Test Message");
trap.add(new VariableBinding(oid, var));
Address targetAddress = new UdpAddress(address);
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(""));
target.setVersion(SnmpConstants.version2c);
target.setAddress(targetAddress);
snmp.send(trap, target, null, null);
System.out.println("DONE......");
}catch(IOException exception){
exception.printStackTrace();
}
}
}
我仍然得到相同的錯誤。 – santro 2011-04-08 08:29:37
我已更新我的答案。請看看它。 – nIKUNJ 2011-04-08 09:23:02
感謝您的信息。 – santro 2011-04-08 09:31:31