afunms

          My Software,My Dream—Forge a more perfect NMS product.

          PSAX Trap 翻譯(1)

               今天終于實(shí)現(xiàn)把朗訊PSAX ATM交換機(jī)的SNMP Trap翻譯成明文的功能。前后花了四天的時(shí)間。

               開始,我想用mibble把a(bǔ)cmib完全解析出來,但折騰了一整天,都沒有結(jié)果,至少最重要的OID是終始出不來,可能是我不會(huì)用mibble吧。

               接著換種思路,用SolarWinds(一個(gè)很好用的mib browser)把a(bǔ)cmib copy成純文本。

                 文本如下:
           

          acMIB     1.3.6.1.4.1.1751.2.18

          connectionConfig   1.3.6.1.4.1.1751.2.18.6

          atmAtmSpvcVccTable   1.3.6.1.4.1.1751.2.18.6.33

          atmAtmSpvcVccEntry   1.3.6.1.4.1.1751.2.18.6.33.1

          atmAtmSpvcVccStatsInOdometerCellCountHiB   1.3.6.1.4.1.1751.2.18.6.33.1.50

          atmAtmSpvcVccStatsInOdometerCellCountLoA 1.3.6.1.4.1.1751.2.18.6.33.1.47

          atmAtmSpvcVccStatsInOdometerCellCountLoB 1.3.6.1.4.1.1751.2.18.6.33.1.51

          atmAtmSpvcVccStatsOdometerReset   1.3.6.1.4.1.1751.2.18.6.33.1.55

          atmAtmSpvcVccStatsOdometerTimer 1.3.6.1.4.1.1751.2.18.6.33.1.54

          atmAtmSpvcVccStatsOutCellCountHiA1.3.6.1.4.1.1751.2.18.6.33.1.37

          atmAtmSpvcVccStatsOutCellCountHiB1.3.6.1.4.1.1751.2.18.6.33.1.41

          atmAtmSpvcVccStatsOutCellCountLoA       1.3.6.1.4.1.1751.2.18.6.33.1.38

          atmAtmSpvcVccStatsOutCellCountLoB       1.3.6.1.4.1.1751.2.18.6.33.1.42

          atmAtmSpvcVccStatsOutOdometerCellCountHiA1.3.6.1.4.1.1751.2.18.6.33.1.48

          atmAtmSpvcVccStatsOutOdometerCellCountHiB1.3.6.1.4.1.1751.2.18.6.33.1.52

          atmAtmSpvcVccStatsOutOdometerCellCountLoA       1.3.6.1.4.1.1751.2.18.6.33.1.49

          atmAtmSpvcVccStatsOutOdometerCellCountLoB       1.3.6.1.4.1.1751.2.18.6.33.1.53

          atmAtmSpvcVccStatsTimer 1.3.6.1.4.1.1751.2.18.6.33.1.43

          atmAtmSpvcVccSusCellRateA2B 1.3.6.1.4.1.1751.2.18.6.33.1.10

          atmAtmSpvcVccSusCellRateB2A 1.3.6.1.4.1.1751.2.18.6.33.1.16

          atmAtmSpvcVccTfcDescModify 1.3.6.1.4.1.1751.2.18.6.33.1.70

          atmAtmSpvcVccTrafficShapingA2B     1.3.6.1.4.1.1751.2.18.6.33.1.64

          atmAtmSpvcVccTrafficShapingB2A     1.3.6.1.4.1.1751.2.18.6.33.1.65

          atmAtmSpvcVccType    1.3.6.1.4.1.1751.2.18.6.33.1.20

          atmAtmSpvcVccVciA    1.3.6.1.4.1.1751.2.18.6.33.1.2

          atmAtmSpvcVccVciB    1.3.6.1.4.1.1751.2.18.6.33.1.6

          atmAtmSpvcVccViA      1.3.6.1.4.1.1751.2.18.6.33.1.56

          ……
           

          把這個(gè)文本導(dǎo)入數(shù)據(jù)庫:

          /**
               * acmib.mib有兩個(gè)版本,此方法把兩個(gè)版本中數(shù)據(jù)都導(dǎo)入數(shù)據(jù)庫.
               * 但保證不會(huì)有重復(fù)的oid
               
          */

              
          public void importOid(){
                  Connection conn 
          =
           ConnectionManager.getConnection();
                  
          try
          {            
                      Statement stat 
          =
           conn.createStatement();
                      BufferedReader in1 
          = new BufferedReader(new FileReader("e:/acmib.txt"
          ));
                      String row 
          = null
          ;
                      
          int id = 1
          ;
                      
          while((row=in1.readLine())!=null)
          {
                          
          int loc = row.indexOf("1.3.6."
          );
                          String symbol 
          = row.substring(0, loc - 1
          ).trim();
                          String oid 
          =
           row.substring(loc).trim();
                          stat.addBatch(
          "insert into acmib_oid(id,oid,symbol)values(" + id + ",'" + oid + "','" + symbol + "')"
          );
                          id
          ++
          ;
                          
          if( id % 100 == 0
          )
                              stat.executeBatch();
                      }

                      stat.executeBatch();
                      
                      ResultSet rs 
          = stat.executeQuery("select oid from acmib_oid order by oid");
                      List
          <String> oids = new ArrayList<String>
          ();
                      
          while
          (rs.next())
                          oids.add(rs.getString(
          1
          ));
                      
                      BufferedReader in2 
          = new BufferedReader(new FileReader("e:/acmib2.txt"
          ));
                      
          while((row=in2.readLine())!=null)
          {
                          String[] rowCols 
          = row.split(" "
          );
                          
          if(oids.contains(rowCols[2])) continue
          ;

                          stat.addBatch(
          "insert into acmib_oid(id,oid,symbol)values(" + id + ",'" + rowCols[2+ "','" + rowCols[1+ "')"
          );
                          id
          ++
          ;
                          
          if( id % 100 == 0
          )
                              stat.executeBatch();
                      }

                      stat.executeBatch();            
                  }
          catch(Exception e){
                      e.printStackTrace();
                  }

              }
          結(jié)果如下:


          posted on 2009-10-21 10:47 afunms 閱讀(247) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊(cè)

          搜索

          最新評(píng)論

          閱讀排行榜

          主站蜘蛛池模板: 汝城县| 珠海市| 增城市| 洪泽县| 射阳县| 靖边县| 香港 | 荃湾区| 运城市| 宝丰县| 绥宁县| 岳池县| 四川省| 皋兰县| 平昌县| 醴陵市| 抚州市| 开封县| 庆安县| 大港区| 莫力| 宜章县| 满洲里市| 疏附县| 田阳县| 舒兰市| 洛隆县| 丰城市| 台江县| 寿阳县| 潮州市| 永清县| 西华县| 皮山县| 富裕县| 建宁县| 永顺县| 丹巴县| 余庆县| 潼关县| 和硕县|