I have created an snmp agent simulator and implemented conceptual row in it.So i want to add an empty row to the MOTable in snmp4j. I tried the code below.
private MOTableRow createEmptyRow(MOTable motable, OID index)
{
Variable[] vars = new Variable[motable.getColumnCount()];
// Arrays.fill(vars, new Integer32(1));
int i = 0;
for (MOColumn column : motable.getColumns()) {
switch (column.getSyntax()) {
case MibConstants.OCTET_STRING: {
vars[i++] = new OctetString();
break;
}
case MibConstants.INTEGER:
case MibConstants.INTEGER32: {
vars[i++] = new Integer32();
break;
}
case MibConstants.COUNTER:
case MibConstants.COUNTER32: {
vars[i++] = new Counter32();
break;
}
case MibConstants.COUNTER64: {
vars[i++] = new Counter64();
break;
}
case MibConstants.IPADDRESS: {
vars[i++] = new IpAddress();
break;
}
case MibConstants.DISPLAYSTRING: {
vars[i++] = new OctetString();
break;
}
case MibConstants.GAUGE:
case MibConstants.GAUGE32: {
vars[i++] = new Gauge32();
break;
}
case MibConstants.OID: {
vars[i++] = new OID();
break;
}
case MibConstants.ROW_STATUS: {
vars[i++] = new Integer32(RowStatus.active);
break;
}
default: {
vars[i++] = new OctetString();
break;
}
}
}
MOTableRow row = DefaultMOFactory.getInstance().createRow(index, vars);
return row;
}
But it some times generates an "Snmp general error" and sometimes a "Bad value"! What exactly wrong here? How can i create an empty row if it's not working? Please help?
Just use SMIConstants
instead of MIBConstants
.
SMIConstants
is a class in SNMP4j
library. But SMIConstants
does not include ROW_STATUS
.