Note that there are some explanatory texts on larger screens.

plurals
  1. POIllegalArgumentException error with snmpget
    primarykey
    data
    text
    <p>I have a jlist for IP addresses and a method to save the selected value from the jlist</p> <pre><code>list.addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e){ s=(String)list.getSelectedValue(); } }); </code></pre> <p>I set the button listener</p> <pre><code>infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SNMP client = new SNMP(); client.snmpGet(ServerFrame.s,"COMMUNAUTE_SERVEUR",".1.3.6.1.2.1.1.5.0"); client.snmpGet(ServerFrame.s,"COMMUNAUTE_SERVEUR","1.3.6.1.2.1.1.1.0"); client.snmpGet(ServerFrame.s,"COMMUNAUTE_SERVEUR",".1.3.6.1.2.1.1.3.0"); } }); </code></pre> <p>This line <code>client.snmpGet(ServerFrame.s,"COMMUNAUTE_SERVEUR",".1.3.6.1.2.1.1.5.0");</code> causes this error:</p> <blockquote> <p>java.lang.IllegalArgumentException: 192.168.1.64 /161<br> at org.snmp4j.smi.UdpAddress.(Unknown Source)</p> </blockquote> <p>This is the <code>snmpget</code> method that i call in the button listener</p> <pre><code>public String snmpGet(String host, String community, String strOID) { String strResponse=""; ResponseEvent response; Snmp snmp; try { OctetString community1 = new OctetString(community); host= host+"/"+"161"; Address tHost = new UdpAddress(host); TransportMapping transport = new DefaultUdpTransportMapping(); transport.listen(); CommunityTarget comtarget = new CommunityTarget(); comtarget.setCommunity(community1); comtarget.setVersion(SnmpConstants.version1); comtarget.setAddress(tHost); comtarget.setRetries(2); comtarget.setTimeout(5000); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(strOID))); pdu.setType(PDU.GET); snmp = new Snmp(transport); response = snmp.get(pdu,comtarget); if(response != null) { if(response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) { PDU pduresponse=response.getResponse(); strResponse=pduresponse.getVariableBindings().firstElement().toString(); if(strResponse.contains("=")) { String strNewResponse = null; int len = strResponse.indexOf("="); strNewResponse=strResponse.substring(len+1, strResponse.length()); System.out.println("The SNMP response to the OID requested is: " + strNewResponse); } } } else { System.out.println("Looks like a TimeOut occured "); } snmp.close(); } catch(Exception e) { e.printStackTrace(); } //System.out.println("Response="+strResponse); return strResponse; } </code></pre> <p>Any help with this error, i get, the problem seems to be with the s variable</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload