This page describes how rows with SNMP values can be added to a SNMP4J-Agent table.

To add a row to a DefaultMOTable

  1. Make sure that the MOTableModel used by the table is an instance of the MutableMOTableModel.

  2. Create the row values as an array of Variable instances:

    Variable[] com2secValues = new Variable[] {
        new OctetString("public"),              // community name
     new OctetString("publicSecName"),       // security name
     getAgent().getContextEngineID(),        // local engine ID
     new OctetString(""),                    // default context name
     new OctetString(),                      // transport tag
     new Integer32(StorageType.nonVolatile), // storage type
     new Integer32(RowStatus.active)         // row status
    }; 
  3. Let the SNMP4J-Agent API create a new row based on the provided values and the index sub-OID for the new row. The new will be created by the MOTableRowFactory assigned to MOMutableTableModel of the snmpCommunityTable. If the row factory is not set (for example to a DefaultMOFactory instance) then an exception will be thrown:

    MOTableRow newRow = snmpCommunityTable.createRow(new OctetString("public").toSubIndex(true), com2secValues); 
  4. Add the newly created row to the table:

    ((MOMutableTableModel)snmpCommunityTable.getModel()).addRow(newRow); 

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.

Related issues