4

snmp GETBULKでルーターのインターフェース情報を取得したいのですが、使用するとレコードの一部しか返ってきませんでした。

コードは以下のとおりです。

public static void main(String[] args) throws IOException, InterruptedException {
    Snmp snmp = new Snmp(new DefaultUdpTransportMapping());
    snmp.listen();

    CommunityTarget target = new CommunityTarget();
    target.setCommunity(new OctetString("public"));
    target.setVersion(SnmpConstants.version2c);
    target.setAddress(new UdpAddress("127.0.0.1/161"));
    target.setTimeout(3000);    //3s
    target.setRetries(1);

    PDU pdu = new PDU();
    pdu.setType(PDU.GETBULK);
    pdu.setMaxRepetitions(200); 
    pdu.setNonRepeaters(0);
    pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.31.1.1.1.1"))); 

    ResponseEvent responseEvent = snmp.send(pdu, target);
    PDU response = responseEvent.getResponse();

    if (response == null) {
        System.out.println("TimeOut...");
    } 
    else 
    {
        if (response.getErrorStatus() == PDU.noError) 
        {
            Vector<? extends VariableBinding> vbs = response.getVariableBindings();
            for (VariableBinding vb : vbs) {
                System.out.println(vb + " ," + vb.getVariable().getSyntaxString());
            }
        } 
        else 
        {
            System.out.println("Error:" + response.getErrorStatusText());
        }
    }
}

実行すると59件のレコードが返ってきますが、GETNEXTで取得すると197件ほど返ってきます。

何か案は?

事前に感謝します。

4

3 に答える 3

4

あなたの反応はどれくらい大きいですか?覚えておいてください - getbulk 応答は単一の UDP パケットに収まる必要があります。これは 65,535 バイトの絶対的な制限です。または、MTU の制限がある場合は、1,500 バイト程度になる可能性があります。

于 2013-07-18T10:14:55.663 に答える