[SNMP4J] Basic Question about implementing SNMP Tables

inliner683 at gmx.de inliner683 at gmx.de
Mon Dec 17 10:28:29 CET 2007


Thanks for the reply. It is an existing MIB, which can't be modified (used in ohter non-java agents), and shall be now in Java Technology. 
And the index columns must be accessible in this case, because they are used to retrieve other data as well. 

As well, you suggest using SMIv2, but the API seems to support SMIv1, so I would be interested in the correct use.

My idea would be to always use the values for the OIDs, so that they are the same. In a first test, this seems to work. Values/OIDs are identical, so a SNMP manager doesn't see any difference.


-------- Original-Nachricht --------
> Datum: Sat, 15 Dec 2007 13:32:30 +0100
> Von: Frank Fock <fock at agentpp.com>
> An: inliner683 at gmx.de
> CC: snmp4j at agentpp.org
> Betreff: Re: [SNMP4J] Basic Question about implementing SNMP Tables

> Hi,
> 
> First, you should use SMIv2 for new MIB modules.
> Second, in SMIv2 all index columns must have
> a maximum access of "not-accessible". Thus,
> there will be no readable index-column - just
> a virtual one.
> 
> Best regards,
> Frank
> 
> inliner683 at gmx.de wrote:
> > Hello,
> > 
> > I want to implement an agent serving a table defined in an own
> > mib. The table rows will be created and deleted only by the agent
> > itself dynamicalle to represent some information of a managed
> application.
> > Cells in the table will be settable via a SNMP manager, but no row
> addition
> > or removal should be possible via the manager.
> > 
> > I will explain my question on the following example. Having the MIB
> > definition as follows:
> > 
> > SOMETABLE-MIB DEFINITIONS ::= BEGIN
> > 
> > IMPORTS
> >        enterprises, OBJECT-TYPE, TimeTicks
> >           FROM RFC1155-SMI
> >        OBJECT-TYPE
> >           FROM RFC-1212;
> > 
> > someCompany           OBJECT IDENTIFIER ::= { enterprises 1234 }
> > someSubTree1          OBJECT IDENTIFIER ::= { someCompany 2 }
> > someSubTree2          OBJECT IDENTIFIER ::= { someSubTree1 2 }
> > 
> > -- Some Table
> > someTable     OBJECT-TYPE
> >               SYNTAX SEQUENCE OF SomeEntry
> >               ACCESS not-accessible
> >               STATUS mandatory
> >               DESCRIPTION ""
> >               ::= { someSubTree2 1 }
> > 
> > someEntry     OBJECT-TYPE
> >               SYNTAX SomeEntry
> >               ACCESS not-accessible
> >               STATUS mandatory
> >               DESCRIPTION ""
> >               INDEX { index }
> >               ::= { someTable 1 }
> > 
> > SomeEntry     ::= SEQUENCE{
> >                            index          INTEGER,
> >                            someID             OCTET STRING,
> >                            someVersion        OCTET STRING
> >                           }
> > 
> > index         OBJECT-TYPE
> >               SYNTAX INTEGER
> >               ACCESS read-only
> >               STATUS mandatory
> >               DESCRIPTION "Row index."
> >               ::= { someEntry 1 }
> > 
> > someID        OBJECT-TYPE
> >               SYNTAX OCTET STRING (SIZE (0..30))
> >               ACCESS read-write
> >               STATUS mandatory
> >               DESCRIPTION ""
> >               ::= { someEntry 2 }
> > 
> > someVersion   OBJECT-TYPE
> >               SYNTAX OCTET STRING (SIZE (0..30))
> >               ACCESS read-write
> >               STATUS mandatory
> >               DESCRIPTION ""
> >               ::= { someEntry 3 }      
> >               
> >     ::= { someSubTree2 2 }         
> > END      
> > 
> > It' a simple table under the enterprises tree. The index column is the
> index of the table, the other
> > columns are settable via SNMP. The table's SomeEntry is under the OID
> .1.3.6.1.4.1.1234.2.2.1.1.
> > 
> > 
> > Now I have an implementation similar to the agenpro generator, first
> defining the OIDs:
> > 
> >     public static final OID oidSomeEntry = new OID(new int[]{1, 3, 6, 1,
> 4, 1, 1234, 2, 2, 1, 1});
> >     public static final OID oidIndex = new OID(new int[]{1, 3, 6, 1, 4,
> 1, 1234, 2, 2, 1, 1, 1});
> > 
> >     public static final int colIndex = 1;
> >     public static final int colSomeID = 2;
> >     public static final int colSomeVersion = 3;
> > 
> >     public static final int idxIndex = 0;
> >     public static final int idxSomeID = 1;
> >     public static final int idxSomeVersion = 2;
> > 
> > The index definition is as follows:
> > 
> >         someEntryIndexes = new
> MOTableSubIndex[]{moFactory.createSubIndex(oidIndex,
> >                 SMIConstants.SYNTAX_INTEGER, 1, 1)};
> >         someEntryIndex = moFactory.createIndex(someEntryIndexes, false);
> > 
> > and the columns and table are created via:
> > 
> >         MOColumn[] someEntryColumns = new MOColumn[3];
> >         someEntryColumns[idxIndex] = moFactory.createColumn(colIndex,
> SMIConstants.SYNTAX_INTEGER,
> >                
> moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY));
> >         someEntryColumns[idxSomeID] = new MOMutableColumn(colSomeID,
> >                 SMIConstants.SYNTAX_OCTET_STRING, moFactory
> >                        
> .createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_WRITE), null);
> >         someEntryColumns[idxSomeVersion] = new
> MOMutableColumn(colSomeVersion,
> >                 SMIConstants.SYNTAX_OCTET_STRING, moFactory
> >                        
> .createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_WRITE), null);
> > 
> >         someEntryModel = moFactory.createTableModel(oidSomeEntry,
> someEntryIndex, someEntryColumns);
> >         ((MOMutableTableModel) someEntryModel).setRowFactory(new
> SomeEntryRowFactory());
> >         someEntry = moFactory.createTable(oidSomeEntry, someEntryIndex,
> someEntryColumns,
> >                 someEntryModel);
> > 
> > This working fine so far and I want to add some rows to the table:
> > 
> > 
> >         Variable v1[] = new Variable[3];
> >         v1[0] = new Integer32(11);
> >         v1[1] = new OctetString("someID1");
> >         v1[2] = new OctetString("someVersion1");
> >         Variable v2[] = new Variable[3];
> >         v2[0] = new Integer32(22);
> >         v2[1] = new OctetString("someID2");
> >         v2[2] = new OctetString("someVersion2");
> >         someEntry.addRow(new SomeEntryRow(new OID("1"), v1));
> >         someEntry.addRow(new SomeEntryRow(new OID("2"), v2));
> > 
> > And this is the part which is confusing me. I would to expect to
> identify the table row via the index
> > column and the base OID. So reading columns someID and someVersion in
> this example I would expect the OIDs
> > 
> > .1.3.6.1.4.1.1234.2.2.1.1.2.11
> > .1.3.6.1.4.1.1234.2.2.1.1.3.11
> > 
> > to be valid. "11" is the value in the index column to identify the row.
> But using a mib browser these oids are invalid, and
> > you must use the oids
> > 
> > .1.3.6.1.4.1.1234.2.2.1.1.2.1
> > .1.3.6.1.4.1.1234.2.2.1.1.3.1
> > 
> > to get the values from 1st row. These are the OIDs used when creating
> the row. What is wrong here and why
> > do I have to provide an (arbitrary?) OID when creating rows. I thought
> the OIDs should be deduced from
> > the index column? This doesn't fit in my understanding of indexing
> tables in SNMP. Here you can provide
> > arbitrary OIDs which will be valid and the index column seems to be of
> no importance.
> > 
> > As well I was wondering when the RowFactory will be used and by whom? Is
> this necessary when creating rows
> > only by the agent itself?
> > 
> > Having answered these questions, I would like to be able to delete the
> table rows by the agent. What would be here the
> > way to go?
> > 
> > Many thanks in advance.
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> 
> -- 
> AGENT++
> http://www.agentpp.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger



More information about the SNMP4J mailing list