[SNMP4J] AgentX shared table indexes problem
Frank Fock
fock at agentpp.com
Mon Mar 5 17:25:15 CET 2012
Hi Jesse,
Please wait until AgentX 2.1 SNAPSHOT. It will be available not
later than Wednesday.
Best regards,
Frank
Am 05.03.2012 14:50, schrieb Jesse Woo:
> Hi Frank,
>
> Shall I overwrite the allocateIndex(..) and deallocateIndex(..) to do nothing for the child table, i.e. return AgentXProtocol.AGENTX_SUCCESS directly?
>
> Without index allocation on master agent, will I get the child row OID as below I wanted?
>
> Is there alternative way doing shared child table without combined index?
>
>> 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 2nd stat of session 10
>> statIndex.10.3 = 3 # represents 3rd stat of session 10
> Thanks,
> Jesse
>
> -----Original Message-----
> From: snmp4j-bounces at agentpp.org [mailto:snmp4j-bounces at agentpp.org] On Behalf Of Frank Fock
> Sent: 02 March 2012 01:00
> To: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] AgentX shared table indexes problem
>
> Hi Jesse,
>
> The behavior you observed is required by the AgentX protocol.
> See RFC 2741 section 7.1.4.2.2 for details.
>
> If you have such an index structure, where you share the index of the master table, then you should not use any index allocation for the child table.
>
> Thus, you should overwrite the methods allocateIndex(..) and deallocateIndex(..) in AgentXSharedMOTableSupport in your own sub-class. Then use that sub-class in your child DefaultAgentXSharedMOTable.
>
> Hope that helps.
>
> Best regards,
> Frank
>
> Am 20.02.2012 14:10, schrieb Jesse Woo:
>> 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 at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
More information about the SNMP4J
mailing list