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
[email protected]
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
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j