0
我試圖做一個程序,發送SNMP查詢到網絡中的一些交換機。使用代理名稱,而不是IP作爲SNMP4J中的地址
使用Net-snmp工具,我可以使用名稱向交換機發送獲取請求,並且工作正常。但SNMP4J需要IP地址CommunityTarget
,所以我得到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);
我如何解決此問題?