I have a MIB contains two tables, main table peerTable and its child table 
statTable.

Each row in peerTable represents one session, and each row of statTable is one 
statistic of a session. Hence the relationship of peerTable and statTable is 
one-to-many.

I have many sessions and want the two tables shared across sessions, and I want 
the tree is built like this,

Say session 10 has 3 statistics

peerIndex.10 = 10 # represents session 10

statIndex.10.1 = 1 # represents 1st stat of session 10
statIndex.10.2 = 2 # represents 1st stat of session 10
statIndex.10.3 = 3 # represents 1st stat of session 10


I have followed sample AgentppTestMib.java and created the two tables as 
DefaultAgentXSharedMOTable.

The peerTable works ok but I can't add any rows to statTable because master 
agent returned error code 259 (AGENTX_INDEX_ALREADY_ALLOCATED) when allocating 
index for statTable.

Seems master can't allocate combined index if one of them is already allocated. 
For example, peerIndex 10 is created for peerTable, and I want to allocate 
index (peerIndx, statIndex) (10,1) for statTable and master rejects it as the 
10 is already allocated.

My question is:

Is it AgentX API bug? If not, is it my MIB not compatible with AgentX? If so, 
how to implement shared table & child tables?


Below are my codes and MIB:

private MOTable<StatEntryRow,
                MOColumn,
                MOTableModel<StatEntryRow>> statEntry;
private MOTableModel<StatEntryRow> statEntryModel;

...

@SuppressWarnings(value={"unchecked"})
private void createStatEntry(MOFactory moFactory) {
  // Index definition
  statEntryIndexes =
    new MOTableSubIndex[] {
    moFactory.createSubIndex(oidPeerIndex,
                             SMIConstants.SYNTAX_INTEGER, 1, 1),
    moFactory.createSubIndex(oidStatIndex,
                           SMIConstants.SYNTAX_INTEGER, 1, 1)    };
...

  // Table model
  statEntryModel =
    moFactory.createTableModel(oidStatEntry,
                               statEntryIndex,
                               statEntryColumns);
  ((MOMutableTableModel<StatEntryRow>)statEntryModel).setRowFactory(
    new StatEntryRowFactory());
  statEntry =
    moFactory.createTable(oidStatEntry,
                          statEntryIndex,
                          statEntryColumns,
                          statEntryModel);
}


@SuppressWarnings("unchecked")
static class CerillionCcs2MOFactory extends DefaultMOFactory {

  public MOTable createTable(OID oid, MOTableIndex indexDef,
                             MOColumn[] columns) {
    if (oidPeerEntry.equals(oid)) {
      return new DefaultAgentXSharedMOTable(oid, indexDef, columns) {
        public void setAgentXSharedMOTableSupport(AgentXSharedMOTableSupport
            sharedTableSupport) {
          super.setAgentXSharedMOTableSupport(sharedTableSupport);
          ((MOMutableTableModel)model).clear();

          OID index =
              new OID(new int[] { 
sharedTableSupport.getSession().getSessionID() });

          // register current session on shared table PeerEntry
          Variable[] vbs = getDefaultValues();
          vbs[idxPeerIndex] = new 
Integer32(sharedTableSupport.getSession().getSessionID());
          vbs[idxPeerName] = new OctetString("Session - " + 
sharedTableSupport.getSession().getSessionID());
          vbs[idxCurrentState] = new 
OctetString(function.getState().toString());

          MOTableRow row = createRow(index, vbs);
          if (row != null) {
            addRow(row);
          }
        }
      };
    }

    if (oidStatEntry.equals(oid)) {
      return new DefaultAgentXSharedMOTable(oid, indexDef, columns) {
        public void setAgentXSharedMOTableSupport(AgentXSharedMOTableSupport
            sharedTableSupport) {
          super.setAgentXSharedMOTableSupport(sharedTableSupport);
          ((MOMutableTableModel)model).clear();

          int sessionId = sharedTableSupport.getSession().getSessionID();

          // add initial stats
          psList = function.getPeerStatistics();
          for (int i=0; psList!=null && i<psList.size(); i++) {
            OID index =
              new OID(new int[] { sessionId,  i+1});

            PeerStatistics ps = psList.get(i);

            Variable[] vbs = getDefaultValues();
            vbs[idxStatIndex] = new Integer32(i+1);
            vbs[idxStatname] = new OctetString(ps.getPeerName() + " of session 
- " + sessionId);
            vbs[idxRecvCount] = new Counter32((int)ps.getReceivedCount());
            vbs[idxSentCount] = new Counter32((int)ps.getSentCount());

            MOTableRow row = createRow(index, vbs);
            if (row != null) {
              addRow(row);
            }
          }
        }
      };
    }
    return new DefaultAgentXSharedMOTable(oid, indexDef, columns);
  }

  public MOTable createTable(OID oid, MOTableIndex indexDef, MOColumn[] columns,
                             MOTableModel model) {
    DefaultAgentXSharedMOTable table =
        (DefaultAgentXSharedMOTable) createTable(oid, indexDef, columns);
    table.setModel(model);
    return table;
  }

}


Here is the MIB:

peerEntry OBJECT-TYPE
    SYNTAX      PeerEntry
    ACCESS      not-accessible
    STATUS      mandatory
    DESCRIPTION "Each entry presents a peer."
    INDEX   { peerIndex }
    ::= { peerTable 1 }

PeerEntry ::= SEQUENCE {
    peerIndex     INTEGER,
    ...
}

peerIndex OBJECT-TYPE
    SYNTAX      INTEGER (1..2147483647)
    ACCESS      read-only
    STATUS      mandatory
    DESCRIPTION "Unique index on peer table."
    ::= { peerEntry 1 }


statEntry OBJECT-TYPE
    SYNTAX      StatEntry
    ACCESS      not-accessible
    STATUS      mandatory
    DESCRIPTION "Each entry represents a statistic of a peer.
                 The peerIndex in the index represents the entry in
                 the peerTable that corresponds to the statEntry.
   INDEX   { peerIndex, statIndex }
    ::= { statTable 1 }


StatEntry ::= SEQUENCE {
    statIndex INTEGER,
    ...
}

statIndex OBJECT-TYPE
    SYNTAX      INTEGER (1..2147483647)
    ACCESS      read-only
    STATUS      mandatory
    DESCRIPTION "A unique value for each statistic of the peer."
    ::= { statEntry 1 }


Regards,
Jesse
Cerillion Technologies Limited
Office. +44 20 7927 6197
Web. www.cerillion.com
Addr. 125 Shaftsbury Avenue, London, WC2H 8AD, UK
_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to