【发布时间】:2016-03-07 17:56:15
【问题描述】:
我正在尝试编写一个程序,将 SNMP 查询发送到网络中的某些交换机。
使用 Net-snmp 工具,我可以使用其名称向交换机发送 get 请求,并且运行良好。但是 SNMP4J 需要 CommunityTarget 中的 IP 地址,所以我得到了 IllegalArgumentException。
这是代码的相关部分:
TransportMapping transport = new DefaultUdpTransportMapping();
transport.listen();
CommunityTarget comtarget = new CommunityTarget();
comtarget.setCommunity(new OctetString("public"));
comtarget.setVersion(SnmpConstants.version1);
comtarget.setAddress(new UdpAddress("switchName")); // exception happens here
comtarget.setRetries(2);
comtarget.setTimeout(1000);
我该如何解决这个问题?
【问题讨论】:
标签: network-programming snmp snmp4j