2013-08-30 7 views
1
나는 테이블에 테이블과 행을 등록하면 snmp4j API를 사용하지만 SNMP 테이블 등록

SNMP4j 에이전트 SNMP 테이블

에 문제가 점점 SNMP 에이전트에 만든

. 그 후 테이블의 값을 모두 설정하면 모든 행이 동일한 값으로 설정됩니다. 제가

.1.3.6.1.4.1.1.201.6.2 설정하면 는하기 표 I에

JSON

에서 생성 SNMP 테이블을 갖는다. 아래 테이블에 등록 된 모든 행의 값을 설정합니다. 누구나 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; 

} 

답변

0

우선 OID는 점으로 시작하지 않습니다 (ASN.1에서 지정한대로).

둘째, 행 인덱스 데이터를 사용하지 않는 것 같습니다. 행은 색인에 의해 식별됩니다.

<tableOID>.1.<rowIndex> 

깡통로 인코딩 된 OID 여러 서브 인덱스 값으로 구성 로우 인덱스 표 인스턴스 OID의 인스턴스 식별자 접미사이다.