首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >snmp4j -无法使用getBulk获取完整记录

snmp4j -无法使用getBulk获取完整记录
EN

Stack Overflow用户
提问于 2013-06-14 13:38:02
回答 1查看 2.8K关注 0票数 0

我尝试使用snmp4j实现snmpgetbulk函数,但无法获取所有记录。它总是返回给我100条记录。有人能在这方面给我一些建议吗?

下面是我的代码:

代码语言:javascript
复制
    //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()); 
            }

          }
EN

回答 1

Stack Overflow用户

发布于 2014-01-06 11:17:08

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17101775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档