SNMP4j代理snmp表

SNMP4j代理snmp表,snmp,snmp4j,Snmp,Snmp4j,我使用snmp4japi在SNMP代理上创建了SNMP,但是SNMP表注册有问题 一旦我注册了一个表和表中的行。然后,如果我在表中设置值,所有行都会设置相同的值。 我已经从JSON创建了snmp表 在下表中,如果我设置值 .1.3.6.1.4.1.1.201.6.2。它为下表中注册的所有行设置值。有人知道如何使用snmmpj代理正确注册和设置值吗 { "tableName": "table1", "tableId": ".1.3.6.1.4.1.1.201.6.

我使用snmp4japi在SNMP代理上创建了SNMP,但是SNMP表注册有问题

一旦我注册了一个表和表中的行。然后,如果我在表中设置值,所有行都会设置相同的值。 我已经从JSON创建了snmp表

在下表中,如果我设置值

.1.3.6.1.4.1.1.201.6.2。它为下表中注册的所有行设置值。有人知道如何使用snmmpj代理正确注册和设置值吗

{
        "tableName": "table1", 
        "tableId": ".1.3.6.1.4.1.1.201.6.1", 
        "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
            },

        ]
    }



 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 = createRow(new Integer(indexStr.trim()), initialValues);
                table.addRow(row);
            }
        }
        }

    return table;

}
{
“表名”:“表1”,
“表格ID”:“.1.3.6.1.4.1.1.201.6.1”,
“栏目”:[
{
“columnName”:“column1”,
“圆柱状”:1,
“数据类型”:70,
“访问类型”:1,
“defaultValue”:0
}, 
{
“columnName”:“column2”,
“圆柱状”:2,
“数据类型”:70,
“访问类型”:1,
“defaultValue”:0
}, 
{
“columnName”:“column3”,
“圆柱状”:3,
“数据类型”:70,
“访问类型”:1,
“defaultValue”:0
},
]
}
公共静态MOTable createTableFromJSON(
JSONObject(对象数据){
MOTable table=null;
如果(数据!=null){
MOTableSubIndex[]子索引=新MOTableSubIndex[]{moFactory
.createSubIndex(null,smicontents.SYNTAX_INTEGER,1100)};
MOTableIndex=moFactory.createIndex(子索引,false,
新的MOTableIndexValidator(){
公共布尔值isValidIndex(OID索引){
布尔值isValidIndex=true;
返回isValidIndex;
}
});
对象indexesObj=data.get(“indexValues”);
if(indexesObj!=null){
字符串索引=data.getString(“indexValues”);
String tableOID=data.getString(“tableId”);
JSONArray columnArray=data.getJSONArray(“columns”);
int columnSize=columnArray.size();
MOColumn[]列=新MOColumn[列大小];
变量[]初始值=新变量[列大小];
对于(int i=0;i
首先,OID不以点开头(按照ASN.1的规定)

其次,您似乎没有使用任何行索引数据。行由其索引标识。行索引是表格实例OID的实例标识符后缀:

<tableOID>.1.<rowIndex>
.1。
can由几个编码为OID的子索引值组成