Agente SNMP en Java: Cómo agregar nuevas filas en MOTable
Estoy tratando de implementar un agente SNMP en Java. Yo uso la biblioteca snmp4j (http://www.snmp4j.org/). Actualmente, mi agente trabaja en localhost / 4700. Intenté enviar una solicitud de snmpget gracias a la siguiente solicitud:
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1
pero solo obtengo algo como "No existe tal instancia actualmente en este OID" Aquí está mi problema: no sé cómo crear uno. Intenté agregar filas a mi MOTable, pero no parece funcionar.
Aquí hay un resumen de mi clase implementando MOGRoup
public class MyMIB
//--AgentGen BEGIN=_EXTENDS
//--AgentGen END
implements MOGroup
//--AgentGen BEGIN=_IMPLEMENTS
//--AgentGen END
{
.
.
.
public static final OID oidTableEntry =
new OID(new int[] { 1,3,6,1,4,1,1,99,5,4,1,3,1 });
.
.
.
private void createTableEntry(MOFactory moFactory) {
// Index definition
.
.
.
// Table model
tableEntryModel =
moFactory.createTableModel(oidTableEntry,
tableEntryIndex,
tableEntryColumns);
((MOMutableTableModel)tableEntryModel).setRowFactory(
new TableEntryRowFactory());
tableEntry =
moFactory.createTable(oidTableEntry,
tableEntryIndex,
tableEntryColumns,
tableEntryModel);
//Adding rows
ArrayList<Integer> oidMon1List= new ArrayList<Integer>();
oidRow1List = this.getListFromArray(oidTableEntry.getValue());
oidRow1List.add(1);
ArrayList<Integer> oidMon2List= new ArrayList<Integer>();
oidRow2List = this.getListFromArray(oidTableEntry.getValue());
oidRow2List.add(2);
DefaultMOMutableTableModel model =
(DefaultMOMutableTableModel)tableEntry.getModel();
synchronized(model){
model.addRow(
model.createRow(
new OID(getArrayFromList(oidRow1List)),
new Variable[]{
new Integer32(123)
}));
model.addRow(
model.createRow(
new OID(getArrayFromList(oidRow2List)),
new Variable[]{
new Integer32(456)
}));
}
}
Pero las peticiones de abajo todavía no funcionan.
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1.0
snmpget -v2c -c public localhost:4700 1.3.6.1.4.1.1.99.5.4.1.3.1.1.1
No debo entender cómo crear filas correctamente. ¿Podría explicarme cómo debo hacer?
Muchas gracias !
Solo un poco de precisión: agregué esas líneas a mi programa:
System.out.println("Get row count: " +tableEntryModel.getRowCount());
//first row
System.out.println("TEST1: " +model.getRow(new OID(new int[] {1,3,6,1,4,1,1,99,5,4,1,3,1,1})).getValue(0));
System.out.println("TEST2: " +tableEntry.getValue(new OID(new int[] {1,3,6,1,4,1,1,99,5,4,1,3,1,1,0})));
Las primeras vueltas: 2 (como se esperaba)
Las segundas vueltas: 123 (como se esperaba)
El tercero regresa: nulo ... aquí, no entiendo por qué!