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