简体   繁体   中英

snmp4j - unable to get full records with getBulk

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()); 
            }

          }

buddy. It seems you've got the same trouble as i have found earlier: SNMP GETBULK Issue: Only could get parts records(Such as 59 records, but there are more than 100 records)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM