[SNMP4J] MOTable

Jose Ignacio jicenteno.listas at gmail.com
Wed Oct 11 11:52:59 CEST 2006


Thanks, but I was already using MOMutableTableModel. I have:

public class TiSnmpTableVar extends DefaultMOTable{
    private Object    mObject;
    private Method    mMethod;

    public TiSnmpTableVar(OID oid, MOTableIndex moTableIndex, MOColumn[]
moColumn)
    {
        super(oid, moTableIndex, moColumn);
        ....
    }

    public Variable getValue (OID oid, int row)
    {
        try{
            return (Variable) mMethod.invoke(mObject, new Object[] { new
Integer(oid), new Integer(row) });
        } ....

        return null;
    }
}

And I use it with:

        MOTableSubIndex[] subIndexes = new MOTableSubIndex[] { new
MOTableSubIndex(SMIConstants.SYNTAX_INTEGER) };
        MOTableIndex indexDef = new MOTableIndex(subIndexes, false);

        MOColumn[] columns = new MOColumn[2];
        int c = 0;
        columns[c++] = new MOColumn(c, SMIConstants.SYNTAX_OCTET_STRING,
MOAccessImpl.ACCESS_READ_ONLY); // ifIndex
        columns[c++] = new MOMutableColumn(c, SMIConstants.SYNTAX_INTEGER32,
MOAccessImpl.ACCESS_READ_WRITE, null); // ifAdminStatuls

        DefaultMOTable myTable = new TiSnmpTableVar(new OID("
1.3.6.1.4.1.4444.2.9"), indexDef, columns);
        MOMutableTableModel model = (MOMutableTableModel) myTable.getModel
();
        Variable[] rowValues1 = new Variable[] { new OctetString("TiSac"),
new Integer32(45) };
        Variable[] rowValues2 = new Variable[] { new OctetString("TiKnows"),
new Integer32(2) };
        Variable[] rowValues3 = new Variable[] { new OctetString("TiFlows"),
new Integer32(5) };
        model.addRow(new DefaultMOMutableRow2PC(new OID("1"), rowValues1));
        model.addRow(new DefaultMOMutableRow2PC(new OID("2"), rowValues2));
        model.addRow(new DefaultMOMutableRow2PC(new OID("3"), rowValues3));

// (DefaultMOServer) mServer
mServer.register(myTable , null);


Then, I need to register all the rows in the table, but I can't do that
because I don't know any value. What I need is that when the server receives
a 1.3.6.1.4.1.4444.2.9.*.* GET request the server asks the value to the
TiSnmpTable object.



On 10/10/06, Frank Fock <fock at agentpp.com> wrote:
>
> Hello Jose,
>
> For virtual table instrumentation implement the MOTableModel and
> use a DefaultMOTable instance with that model. This is by far
> better and a lot easier than implementing your own command processor
> (even better than doing that, would be implementing a sub-class
> of ManagedObject).
>
> Best regards,
> Frank
>
> Jose Ignacio wrote:
> > Hello, now I have a more interesting problem.I think it's better to
> explain
> > with an example:
> >
> > I need to send 'user id' with 'users last loggin'. I do it with
> MyMOTable
> > (that extends DefaultTable). getValue method calls getCell(row,col)
> method
> > from class Users and that one returns the Variable result.
> >
> > The problem is that the number of users is unknown so I can't register
> all
> > rows on the table (I can't use a listener because now the values are in
> a
> > table, but later they can be in memory, ...). I have thought to write a
> > commandProcessor wich sends all requests that begins with the table OID
> to
> > class Users.
> >
> > For exameple: If we have oid 1.2.3 for the table, then all request for
> > 1.2.3.* are sent to Users class.
> >
> >
> > Thanks
> > --
> > Jose Ignacio
> > _______________________________________________
> > SNMP4J mailing list
> > SNMP4J at agentpp.org
> > http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> --
> AGENT++
> http://www.agentpp.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com
>
>



More information about the SNMP4J mailing list