[SNMP4J] SNMP table : row data get override by the recent rows
Frank Fock
fock at agentpp.com
Tue Sep 10 18:49:46 CEST 2013
Hi,
How is the variable "id" initialized in row
MOTableRow<Variable> row =
moFactory.createRow(new OID(new int[] { id }), initialValues);
I do not see that anywhere.
Please fix your code first, before asking again. Also a simpler
code example would be helpful, which conentrates on the SNMP4J-Agent
code and not your project stuff.
Best regards,
Frank
Am 10.09.2013 12:40, schrieb Sumit Sharma:
>
> Hi All and Frank,
>
> Let me explain you the problem in bit detail.
>
> I have created an SNMP Agent which supports v3 protocol. As you know
> before start agent we have to register oid and table.
>
> We are registering mo objects (MOScalar and MOTable) to snmp agent
> using below code.
>
> *server.register(mo, null);*
>
> To create MO table we keep table configuration of table and scalar in
> json structure. For example we want to register a motable with OID
> .1.3.6.1.4.1.1.201.6.1 where .1 is table entry id.
>
> where column information is mentioned in json format.
>
> After createTableFromJSON method call (method detail in below
> email) motable is successfully created and registered in DefautMOServer.
>
> but once agent start and i try to set the value with the help of below
> code.
>
> VariableBinding binding = new VariableBinding();
>
> binding.setOid(new OID(".1.3.6.1.4.1.1.201.6.1.2.1"));
>
> binding.setVariable(new Counter64(20L);
>
> server.setValue(server, null, binding);
>
> Ideally 20L should be set for Column id 2 and row id or (Index id) 1
> as mentiond and highlighted in blue. but value got copied over to all
> rows.
>
> Please let me know if i can call you on your number to describe you
> the problem if i am not able to clarify it with this email.
>
> Thanks in advance for help as i am very much stuck due to this
> problem. Please help.
>
> *JSON structure for registration*
>
> {
>
> "tableName": "table1",
>
> "tableId": ".1.3.6.1.4.1.1.201.6.1",
>
> indexValues: "1;2;3"
>
> "columns": [
>
> {
>
> "columnName": "column1",
>
> "columnOID": 1,
>
> "dataType": 70,
>
> "accessType": 1,
>
> "defaultValue":0
>
> },
>
> {
>
> "columnName": "column2",
>
> "columnOID": 2,
>
> "dataType": 70,
>
> "accessType": 1,
>
> "defaultValue":0
>
> },
>
> {
>
> "columnName": "column3",
>
> "columnOID": 3,
>
> "dataType": 70,
>
> "accessType": 1,
>
> "defaultValue":0
>
> },
>
>
> ]
>
> }
>
> *Method for MOTable creation*
>
> *We are using this mofactory in below method *MOFactory moFactory =
> DefaultMOFactory.getInstance()
>
> public static MOTable<MOTableRow<Variable>, MOColumn<Variable>,
> MOTableModel<MOTableRow<Variable>>> createTableFromJSON(
>
> JSONObject data) {
>
> MOTable table = null;
>
> if (data != null) {
>
> MOTableSubIndex[] subIndex = new MOTableSubIndex[] { moFactory
>
> .createSubIndex(null, SMIConstants.SYNTAX_INTEGER, 1,
> 100) };
>
> MOTableIndex index = moFactory.createIndex(subIndex, false,
>
> new MOTableIndexValidator() {
>
> public boolean isValidIndex(OID index) {
>
> boolean isValidIndex = true;
>
> return isValidIndex;
>
> }
>
> });
>
> Object indexesObj = data.get("indexValues");
>
> if(indexesObj!=null){
>
> String indexes = data.getString("indexValues");
>
> String tableOID = data.getString("tableId");
>
> JSONArray columnArray = data.getJSONArray("columns");
>
> int columnSize = columnArray.size();
>
> MOColumn[] columns = new MOColumn[columnSize];
>
> Variable[] initialValues = new Variable[columnSize];
>
> for (int i = 0; i < columnSize; i++) {
>
> JSONObject columnObject = columnArray.getJSONObject(i);
>
> columns[i] = moFactory.createColumn(columnObject
>
> .getInt("columnOID"),
> columnObject.getInt("dataType"),
>
> moFactory.createAccess(columnObject
>
> .getInt("accessType")));
>
> initialValues[i] =
> getVariable(columnObject.get("defaultValue"));
>
> }
>
> MOTableModel tableModel = moFactory.createTableModel(new OID(
>
> tableOID), index, columns);
>
> table = moFactory.createTable(new OID(tableOID), index,
> columns,
>
> tableModel);
>
> String[] indexArrString = indexes.split(";");
>
> for(String indexStr: indexArrString){
>
> MOTableRow<Variable> row =
> moFactory.createRow(new OID(new int[] { id }), initialValues);
>
> table.addRow(row);
>
> }
>
> }
>
> }
>
> return table;
>
> }
>
> Thanks | Sumit Sharma
>
>
> ------------------------------------------------------------------------
>
>
>
>
>
>
> NOTE: This message may contain information that is confidential,
> proprietary, privileged or otherwise protected by law. The message is
> intended solely for the named addressee. If received in error, please
> destroy and notify the sender. Any use of this email is prohibited
> when received in error. Impetus does not represent, warrant and/or
> guarantee, that the integrity of this communication has been
> maintained nor that the communication is free of errors, virus,
> interception or interference.
--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax: +49 7024 8688231
More information about the SNMP4J
mailing list