“版本不正确或解码错误”发送陷阱时
我在管理器端收到“版本不正确或解码错误”。我是 只是想知道以下示例陷阱发送器代码是否缺少某些内容。
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();
}
}
}
I am getting "Incorrect Version or decode error" on manager side. I was
just wondering if there is something missing with the following sample trap sender code.
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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下,
我认为你的代码是正确的。但您可以尝试使用我的代码:
我希望它会有所帮助。
Try with,
I think your code is right. But you can try using my code:
I hope it will help.