Results 1 to 2 of 2
  1. #1
    easymod is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Question get-response problem (snmp4j)

    Hi,
    I have problem with function get-response, when I do a request to my cisco switch with different OID, for example:
    Java Code:
                PDU pdu = new PDU();
                pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.9.9.109.1.1.1.1.4"))); // cpmCPUTotal1min
                pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.6.13.1.3"))); // tcpConnLocalPort
                pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.14179.2.3.1.125"))); // obviously incorrect OID for test
                pdu.setType(PDU.GETNEXT);
    then I get response:
    1) 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 = 22
    2) 1.3.6.1.2.1.6.13.1.3.10.100.112.2.22.10.100.112.66 .2935 = 22
    3) 1.3.6.1.6.3.1.1.6.1.0 = 0

    1) why snmp4j returns 1.3.6.1.4.1.9.9.109.1.1.1.1.4.1 instead of 1.3.6.1.4.1.9.9.109.1.1.1.1.4?
    2 & 3) why snmp4j returns another OID 1.3.6.1.2.1.6.13.1.3.10.100.112.2.22.10.100.112.66 .2935, but not OID that I requested? On official CISCO site 1.3.6.1.2.1.6.13.1.3.10.100.112.2.22.10.100.112.66 .2935:
    Object Information
    Unfortunately we could not translate the object 1.3.6.1.2.1.6.13.1.3.10.100.112.2.22.10.100.112.66 .2935 you were looking for. We could however translate a part of your object. This is the partial translation:
    iso . org . dod . internet . mgmt . mib-2 . tcp . tcpConnTable . tcpConnEntry . tcpConnLocalPort . 10 . 100 . 112 . 2 . 22 . 10 . 100 . 112 . 66 . 2935.
    Why not present error exception or change ErrorStatus?:mad:
    How to determine that the device does not know such OID by the result of response?:confused:

    Code my program:
    public class test
    {
    public static void main(String[] args)
    {
    String str = "";
    Address targetAddress = GenericAddress.parse("udp:192.168.0.12/161");
    TransportMapping transport= null;
    try {
    transport = new DefaultUdpTransportMapping();
    Snmp snmp = new Snmp(transport);
    transport.listen();

    // setting up target
    CommunityTarget target = new CommunityTarget();
    target.setCommunity(new OctetString("public"));
    target.setAddress(targetAddress);
    target.setRetries(2);
    target.setTimeout(1500);
    target.setVersion(SnmpConstants.version2c);

    // creating PDU
    PDU pdu = new PDU();
    pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.9.9.109.1.1.1.1.4.1")));
    pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.6.13.1.3")));
    pdu.add(new VariableBinding(new OID("1.3.6.1.4.1.14179.2.3.1.125")));
    pdu.setType(PDU.GETNEXT);

    ResponseEvent response = null;
    response = snmp.send(pdu, target);

    if(response != null && response.getResponse() != null)
    {

    if(response.getResponse().getErrorStatus() == SnmpConstants.SNMP_ERROR_SUCCESS)
    {
    PDU pduresponse=response.getResponse();

    for(int i = 0; i < pduresponse.getVariableBindings().size(); i++)
    {
    //if (((VariableBinding)pduresponse.getVariableBindings ().elementAt(i)).getOid().toString().equals(((Vari ableBinding)pdu.getVariableBindings().elementAt(i) ).getOid().toString() + ".1"))
    str+=pduresponse.getVariableBindings().elementAt(i ).toString()+'\n';
    //else
    //str+=pduresponse.getVariableBindings().elementAt(i ).toString().substring(0, pduresponse.getVariableBindings().elementAt(i).toS tring().indexOf("=")) + " Not Found\n";
    }
    }
    else
    System.out.println(response.getResponse().getError StatusText());
    }
    else
    System.out.println("Timeout.");
    snmp.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    System.out.println("Response=\n"+str);
    System.out.println("Done.");
    }
    }
    Hope someone can help me.

    Regards,
    easymod.
    Last edited by easymod; 07-01-2010 at 09:09 AM.

  2. #2
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Re: get-response problem (snmp4j)

    When i tried to query the Agent the response PDU is null for certain OID's . If response PDU is null can we consider the Agent is down. ? But the Agent is up only. is there a way to find out from teh response PDU whether the Agent is UP/Down ?.

Similar Threads

  1. response.setContentType
    By bbq in forum Java Servlet
    Replies: 3
    Last Post: 01-17-2012, 06:37 PM
  2. Replies: 0
    Last Post: 06-07-2010, 08:48 AM
  3. SNMP4j API
    By cassanova in forum Networking
    Replies: 0
    Last Post: 03-18-2010, 11:22 PM
  4. Replies: 4
    Last Post: 10-02-2008, 07:32 PM
  5. response.sendRedirect problem
    By christina in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-03-2007, 06:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •