[SNMP4J] Basic Question about implementing SNMP Tables

inliner683 at gmx.de inliner683 at gmx.de
Thu Dec 13 15:04:16 CET 2007


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.







-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser



More information about the SNMP4J mailing list