[SNMP4J] getTable usage
Marco.Bresciani at alcatel.it
Marco.Bresciani at alcatel.it
Mon Jan 23 17:50:02 CET 2006
Hi all,
I've read almost all past posts about getTable... but I've found not
useful answer. :-(
As I solved my previous (single) objects GETs/SETs problems, I'm now
working on getting tables.
I fortunately have OIDs indexes of columns and table OID in the method
I'm renewing (no OIDs in another method I'll have to analyse... and I'll
probably write about it as soon as I'll finish this one...). Anyway.
Trying to get a table I wrote this:
...
TableUtils table = new TableUtils(snmp, new
DefaultPDUFactory(PDU.GETBULK));
List results;
OID[] indexes = new OID[columnIndexes.length];
for (int i = 0; i < columnIndexes.length; i++) {
indexes[i] = new OID((String) (tableOid + columnIndexes[i][0]));
}
results = table.getTable(device, (OID[]) indexes, null, null);
if (results != null) {
TableEvent response;
for (int i = 0; i < results.size(); i++) {
response = (TableEvent) results.get(i); /* I was forgetting
casting... too used to Java 1.5... */
}
...
And I've tried to use any from GET, GETNEXT and GETBULK into
DefaulPDUFactory constructor... So: this part of code sends a GET on the
table (data from Ethereal):
No. Time Source Destination Protocol
Info
1 0.000000 10.0.1.55 10.0.1.2 SNMP
GETBULK iso.3.6.1.4.1.637.54.1.1.6.1.8.1.5
Simple Network Management Protocol
Version: 2C (1)
Community: public
PDU type: GETBULK (5)
Request Id: 0x000009c9
Non-repeaters: 0
Max repetitions: 30
Object identifier 1: 1.3.6.1.4.1.637.54.1.1.6.1.8.1.5
(iso.3.6.1.4.1.637.54.1.1.6.1.8.1.5)
Value: NULL
And this thing gives me back some data...
Simple Network Management Protocol
Version: 2C (1)
Community: public
PDU type: RESPONSE (2)
Request Id: 0x000009c9
Error Status: NO ERROR (0)
Error Index: 0
Object identifier 1: 1.3.6.1.4.1.637.54.1.1.6.1.8.1.5.2
(iso.3.6.1.4.1.637.54.1.1.6.1.8.1.5.2)
Value: INTEGER: 4
Object identifier 2: 1.3.6.1.4.1.637.54.1.1.6.1.8.1.6.2
(iso.3.6.1.4.1.637.54.1.1.6.1.8.1.6.2)
Value: INTEGER: 1
Object identifier 3: 1.3.6.1.4.1.637.54.1.1.6.1.10.1.2.0
(iso.3.6.1.4.1.637.54.1.1.6.1.10.1.2.0)
Value: IpAddress: 0.0.0.0
Object identifier 4: 1.3.6.1.4.1.637.54.1.1.6.1.10.1.3.0
(iso.3.6.1.4.1.637.54.1.1.6.1.10.1.3.0)
Value: IpAddress: 0.0.0.0
Object identifier 5: 1.3.6.1.4.1.637.54.1.1.6.1.10.1.4.0
(iso.3.6.1.4.1.637.54.1.1.6.1.10.1.4.0)
Value: INTEGER: 2
Object identifier 6: 1.3.6.1.4.1.637.54.1.1.6.1.10.1.5.0
(iso.3.6.1.4.1.637.54.1.1.6.1.10.1.5.0)
Value: INTEGER: 1
Object identifier 7: 1.3.6.1.4.1.637.54.1.1.6.1.11.1.2.151.98.170.0
(iso.3.6.1.4.1.637.54.1.1.6.1.11.1.2.151.98.170.0)
Value: IpAddress: 255.255.254.0
Object identifier 8: 1.3.6.1.4.1.637.54.1.1.6.1.11.1.3.151.98.170.0
(iso.3.6.1.4.1.637.54.1.1.6.1.11.1.3.151.98.170.0)
Value: IpAddress: 151.98.141.65
Object identifier 9: 1.3.6.1.4.1.637.54.1.1.6.1.11.1.4.151.98.170.0
(iso.3.6.1.4.1.637.54.1.1.6.1.11.1.4.151.98.170.0)
Value: INTEGER: 0
Object identifier 10: 1.3.6.1.4.1.637.54.1.1.6.1.11.1.5.151.98.170.0
(iso.3.6.1.4.1.637.54.1.1.6.1.11.1.5.151.98.170.0)
Value: INTEGER: 1
Object identifier 11: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.2.10.0.1.2
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.2.10.0.1.2)
Value: IpAddress: 255.255.255.255
Object identifier 12: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.2.10.0.1.55
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.2.10.0.1.55)
Value: IpAddress: 255.255.255.255
Object identifier 13: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.2.127.0.0.1
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.2.127.0.0.1)
Value: IpAddress: 255.255.255.255
Object identifier 14: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.3.10.0.1.2
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.3.10.0.1.2)
Value: IpAddress: 10.0.1.2
Object identifier 15: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.3.10.0.1.55
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.3.10.0.1.55)
Value: IpAddress: 10.0.1.2
Object identifier 16: 1.3.6.1.4.1.637.54.1.1.6.1.12.1.3.127.0.0.1
(iso.3.6.1.4.1.637.54.1.1.6.1.12.1.3.127.0.0.1)
Value: IpAddress: 127.0.0.1
Frame 3 (392 bytes on wire, 392 bytes captured)
Data (353 bytes)
Okay... but... why, while I have a reply:
results = table.getTable(device, (OID[]) indexes, null, null);
if (results != null) {
... this part above get correct and results is not null...
TableEvent response;
for (int i = 0; i < results.size(); i++) {
response = (TableEvent) results.get(i); /* I was forgetting
casting... too used to Java 1.5... */
}
... its size is 0?! It seems I have no results in the results List... :-(
Could anyone help me, please?
Thank you for any help,
Dott. Ing. Marco Bresciani
--
Alcatel - WTD R&D SW Lab. [Stage]
Via Trento, 30
20059 Vimercate (Mi) Italia
Phone: +39.039.686.5546
E-Mail: Marco.Bresciani at Alcatel.It
More information about the SNMP4J
mailing list