So I'm using snmp4j agent 2.7 and registering MOTable. So problem is, oid is in the wrong order.
It's tableOID.column.row, I want it to tableOID.row.column.
Here is my code:
MOFactory moFactory = DefaultMOFactory.getInstance();
MOTableSubIndex[] someEntryIndexes =
new MOTableSubIndex[] {moFactory.createSubIndex(OIDIndex, SMIConstants.SYNTAX_INTEGER, 1, 32)};
MOTableIndex index = moFactory.createIndex(someEntryIndexes, true);
MOColumn[] columns = new MOColumn[3];
columns[0] = moFactory.createColumn(1, SMIConstants.SYNTAX_INTEGER,
moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY));
columns[1] = new MOMutableColumn(2,
SMIConstants.SYNTAX_OCTET_STRING, moFactory
.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY), null);
columns[2] = new MOMutableColumn(3,
SMIConstants.SYNTAX_OCTET_STRING, moFactory
.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY), null);
DefaultMOTableModel tableModel = moFactory.createTableModel(rootOid, index, columns);
((MOMutableTableModel)tableModel).setRowFactory(new SomeEntryRowFactory());
MOTable table = moFactory.createTable(rootOid, index, columns, tableModel);
List<String[]> list = Arrays.asList(new String[] {"r1, c1", "r1, c2", "r1, c3"}, new String[] { "r2, c1", "r2, c2", "r2, c3"});
for(int i=0; i <= list.size()-1; i++) {
Variable[] vars = new Variable[] {new OctetString(list.get(i)[0]), new OctetString(list.get(i)[1]), new OctetString(list.get(i)[2])};
table.addRow(table.createRow(new OID(Integer.toString(i)), vars));
}
my output is:
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.4.1.5432.3.2.1.1
iso.3.6.1.4.1.5432.3.2.1.1.0 = STRING: "r1, c1"
iso.3.6.1.4.1.5432.3.2.1.1.1 = STRING: "r2, c1"
wanted output is:
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.4.1.5432.3.2.1.1
iso.3.6.1.4.1.5432.3.2.1.1.0 = STRING: "r1, c1"
iso.3.6.1.4.1.5432.3.2.1.1.1 = STRING: "r1, c2"
iso.3.6.1.4.1.5432.3.2.1.1.2 = STRING: "r1, c3"
what I should do to fix this?