0

I try to implement snmpgetbulk function using snmp4j and failed to get the all the records. It always return me the 100 records. Can anyone can advice me on this?

Below is my code:

    //create transport
        transport = new DefaultUdpTransportMapping();
        CommunityTarget target = new CommunityTarget(); 
        target.setCommunity(new OctetString("public"));
        target.setAddress(targetAddress); 
        target.setRetries(3); 
        target.setTimeout(5000); 
        target.setVersion(1); 

        // create the PDU 
        PDU pdu = new PDU(); 
        pdu.setType(PDU.GETBULK);

        //put the oid you want to get
        pdu.add(new VariableBinding(new OID(oid)));
        pdu.setMaxRepetitions(150);

        //pdu string
        System.out.println("pdu " + pdu.toString());             

        response = snmp.getBulk(pdu,target);
        System.out.println("pdu.size>>"+pdu.size());
        if(response != null) {
          if(response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) {
            PDU pduresponse=response.getResponse();
            Vector vec = pduresponse.getVariableBindings();
            System.out.println("snmpwalk2>> size>>"+vec.size());
            for(int i=0; i<vec.size(); i++){
                VariableBinding vb = null; 
                 vb = (VariableBinding)vec.elementAt(i); 
                 //System.out.println(i+ " ---- "+vb.toString()); 
            }

          }
4

1 回答 1

0

伙伴。看来您遇到了和我之前发现的一样的麻烦:SNMP GETBULK 问题:只能获取部分记录(如 59 条记录,但有 100 多条记录)

于 2014-01-06T03:17:07.753 回答