[SNMP4J] Fwd: Fwd: Table Model

Aiman Farhat aiman.farhat at gmail.com
Fri May 3 11:57:22 CEST 2013


Hi Frank,

 Thanks for your response. According to instrumentation guide I am updating
the table model before the request is processed based on external event.
Our table will be small tables doesn't exceed 20 row max. The problem we
are having is not with the order, it is actually with the content. I have
a test data as follow:

Set1:
Component_set1_1
Component_set1_2
Component_set1_3

Set2:
Component_set2_1
Component_set2_2
Component_set2_3

When I send a request from a Mib browser, the table content gets mixed. For
example the data in the table could be something like that:

Component_set1_1
Component_set2_2
Component_set1_3

Which is not what I have expected as my model should have either Set1 or
Set2 but not mix of both.

As you know I am implementing MOServerLookupListener interface and in
queryEvent(MOServerLookupEvent event)  I am building my table model. I know
queryEvent method get called multiple times based on number of columns and
rows, and maybe that's why I am getting mixed results even though I am
clearing the model.

I am sure I am doing something wrong, and appricate your help.

Thanks.
AF



On Thu, May 2, 2013 at 4:28 PM, Frank Fock <fock at agentpp.com> wrote:

> Hi,
>
> I think the table works perfectly. The ordering is correct.
> (I know that this is not what you expected to hear ;-) )
>
> OK, first some words on the background: As you might
> already know, SNMP does not have a PDU or service
> called "getTable". Instead you have GETNEXT and GETBULK
> and an absolut upper limit of 64K per PDU (UDP).
>
> Thus, medium and large tables will be never fetched with
> a single Request->Response communication. If you alter
> your table for each request, the command generator
> (= sender of the requests) will see "incosistent" data,
> because you provided incosistent data.
>
> Besides, it takes a lot CPU time, to recreate the table
> for each request.
>
> You can improve your code by updating the table only
> every 2-5 seconds and not more often as a client would
> typically need to fetch the whole table.
>
> Best regards,
> Frank
>
>
>
>
> Am 02.05.2013 14:30, schrieb Aiman Farhat:
>
>> Hi All,
>>
>> The problem I am facing with snmp4j is as follow, I am building a
>> *dynamic*table model, where every time a request comes I clear the old
>>
>> data and then
>> recreate it. The Issue I am facing is when I am sending subsequent
>> requests
>> the data model is not returning the correct rows. Just to give you an
>> example:
>>
>> As a test the data I am sending back to the request either:
>>
>>
>>
>> Set A:
>>
>> Component1
>>
>> Component2
>>
>> Component3
>>
>> Component4
>>
>> Component5
>>
>> Component6
>>
>>
>> OR
>>
>>
>> Set B:
>>
>> Component11
>>
>> Component22
>>
>> Component33
>>
>> Component44
>>
>> Component55
>>
>> Component66
>>
>>
>>
>> Now the problem as follow:
>>
>> I see the following results in the Mib browser returned:
>>
>> Component1
>>
>> Component22
>>
>> Component3
>>
>> Component44
>>
>> Component55
>>
>> Component6
>>
>>
>> As you can see the values in the table model is not what I have expected.
>> As when I am building the table model I am clearing the old data then re
>> populated with either set A or Set B
>>
>> of dummy values.
>>
>>
>>
>> Just to elaborate more from code prospective :
>>
>>
>>
>> T*his is building the table section:*
>>
>>
>>
>>
>> DefaultMOTable table = new DefaultMOTable(tableRootOid, indexDef,
>>
>>                                                  columns.toArray(new
>> MOColumn[0]));
>>
>> MOMutableTableModel model = (MOMutableTableModel) table.getModel();
>>
>>
>>
>> int i = 1;
>>
>>
>>
>> for (Variable[] variables : tableRows) {
>>
>>      model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)),
>> variables));
>>
>>      i++;
>>
>> }
>>
>> table.setVolatile(true);
>>
>> return table;
>>
>>
>>
>> This section details the registration of the managed Table Object
>>
>>
>> server.register(table, null);
>>
>> server.addLookupListener(new DeployedComponentListener(**table), table);
>>
>>
>>
>>
>> And this is my Listener class implementation
>>
>>
>>
>> @Override
>>
>> *public* *void* queryEvent(MOServerLookupEvent event) {
>>
>>
>>
>> *DefaultMOTable* table = (*DefaultMOTable*) event.getLookupResult();
>>
>>                             MOMutableTableModel<**DefaultMOMutableRow2PC>
>> model = *(MOMutableTableModel<**DefaultMOMutableRow2PC>)
>> table.getModel()*;
>>
>>
>>
>>                             *synchronized* (model) {
>>
>>
>>
>>                                    model.clear();
>>
>>                                    Random r = *new* Random();
>>
>>
>>
>>                                    *int* rand = r.nextInt(2);
>>
>>
>>
>>                                    *if* (rand == 0) {
>>
>>
>>
>>                                           Variable[] var1 = *new*
>> Variable[]
>> { *new* Integer32(1),
>>
>>                                                         *new* OctetString(
>> "Component1"),
>>
>>                                                         *new*
>> OctetString("Component1
>> version"),
>>
>>                                                         *new*
>> OctetString("Component1
>> revision"),
>>
>>                                                         *new*
>>
>> OctetString("Component1
>> insenace id"),
>>
>>                                                         *new*
>> OctetString("")
>> };
>>
>>
>>
>>                                           more var…..
>>
>>
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("1"), var1));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("2"), var2));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("3"), var3));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("4"), var4));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("5"), var5));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("6"), var6));
>>
>>
>>
>>                                    } *else* {
>>
>>
>>
>>                                           Variable[] var1 = *new*
>> Variable[]
>> { *new* Integer32(1),
>>
>>                                                         *new* OctetString(
>> "Component11"),
>>
>>                                                         *new*
>> OctetString(""
>> ),
>>
>>                                                         *new*
>> OctetString(""
>> ),
>>
>>                                                         *new*
>> OctetString(""
>> ),
>>
>>                                                         *new*
>> OctetString("")
>> };
>>
>>
>>
>>                                            more  var
>>
>>
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("1"), var1));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("2"), var2));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("3"), var3));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("4"), var4));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("5"), var5));
>>
>>
>> model.addRow(*new***DefaultMOMutableRow2PC(
>> *new* OID("6"), var6));
>>
>>
>>                                    }
>>
>>                             }
>>
>>
>> I am following the AgentPro instrumentation guide this the only guide I
>> could find on how to build the table model.
>>
>> Thanks
>>
>> AF
>> ______________________________**_________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/**mailman/listinfo/snmp4j<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
>
> ______________________________**_________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/**mailman/listinfo/snmp4j<http://lists.agentpp.org/mailman/listinfo/snmp4j>
>



More information about the SNMP4J mailing list