コード例 #1
0
 public BaseVo loadFromRS(ResultSet rs) {
   Oraspaceconfig vo = new Oraspaceconfig();
   try {
     vo.setId(rs.getInt("id"));
     vo.setIpaddress(rs.getString("ipaddress"));
     vo.setSpacename(rs.getString("spacename"));
     vo.setLinkuse(rs.getString("linkuse"));
     vo.setAlarmvalue(rs.getInt("alarmvalue"));
     vo.setBak(rs.getString("bak"));
     vo.setReportflag(rs.getInt("reportflag"));
     vo.setSms(rs.getInt("sms"));
   } catch (Exception e) {
     e.printStackTrace();
     // SysLogger.info("EventListDao.loadFromRS()",e);
     vo = null;
   }
   return vo;
 }
コード例 #2
0
  /*
   *
   * 从内存和数据库表里获取每个IP的端口信息,存入端口配置表里
   */
  public void fromLastToOraspaceconfig() throws Exception {
    List list = new ArrayList();
    List list1 = new ArrayList();
    List shareList = new ArrayList();
    Hashtable oraspacehash = new Hashtable();
    Session session = null;
    Vector configV = new Vector();
    IpTranslation tranfer = new IpTranslation();
    try {
      // 从ORASPACCE配置表里获取列表
      rs = conn.executeQuery("select * from system_oraspaceconf order by ipaddress");
      while (rs.next()) list1.add(loadFromRS(rs));
      if (list1 != null && list1.size() > 0) {
        for (int i = 0; i < list1.size(); i++) {
          Oraspaceconfig oraspaceconfig = (Oraspaceconfig) list1.get(i);
          // IP:表空间名称

          oraspacehash.put(
              oraspaceconfig.getIpaddress() + ":" + oraspaceconfig.getSpacename(), oraspaceconfig);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    try {

      // 从内存中得到所有ORASPACCE采集信息
      Hashtable sharedata = ShareData.getOraspacedata();

      // 从数据库得到监视ORASPACCE列表
      DBDao dbdao = new DBDao();
      DBTypeDao typedao = new DBTypeDao();
      DBTypeVo typevo = typedao.findByDbtype("oracle");
      shareList = dbdao.getDbByTypeMonFlag(typevo.getId(), 1);
      if (shareList != null && shareList.size() > 0) {
        for (int i = 0; i < shareList.size(); i++) {
          //					OraclePartsDao oracleDao=null;
          try {
            DBVo dbmonitorlist = (DBVo) shareList.get(i);
            //						 oracleDao=new OraclePartsDao();
            //						List<OracleEntity> oracles=oracleDao.findOracleParts(dbmonitorlist.getId());
            //						for(OracleEntity ora:oracles){
            //
            //						}
            if (sharedata.get(dbmonitorlist.getIpAddress() + ":" + dbmonitorlist.getId()) != null) {
              Vector tableinfo_v =
                  (Vector)
                      sharedata.get(dbmonitorlist.getIpAddress() + ":" + dbmonitorlist.getId());
              if (tableinfo_v == null) continue;
              Hashtable spaces = new Hashtable();
              spaces.put("ip", dbmonitorlist.getIpAddress() + ":" + dbmonitorlist.getId());
              spaces.put("tableinfo_v", tableinfo_v);
              list.add(spaces);
            }
          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            //						if(oracleDao!=null)
            //						  oracleDao.close();
          }
        }
      }
      // 判断采集到的ORASPACCE信息是否已经在ORASPACCE配置表里已经存在,若不存在则加入
      if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
          Hashtable spaces = (Hashtable) list.get(i);
          if (spaces != null && spaces.size() > 0) {
            String ip = (String) spaces.get("ip");
            Vector tableinfo_v = (Vector) spaces.get("tableinfo_v");
            if (tableinfo_v != null && tableinfo_v.size() > 0) {
              Oraspaceconfig oraspaceconfig = null;
              for (int k = 0; k < tableinfo_v.size(); k++) {
                Hashtable return_value = (Hashtable) tableinfo_v.get(k);
                String spacename = (String) return_value.get("tablespace");
                String[] iparr = ip.split(":");
                String tip = tranfer.formIpToHex(iparr[0]);
                if (!oraspacehash.containsKey(tip + ":" + iparr[1] + ":" + spacename)) {
                  oraspaceconfig = new Oraspaceconfig();
                  oraspaceconfig.setSpacename(spacename);
                  oraspaceconfig.setBak("");
                  oraspaceconfig.setIpaddress(tip + ":" + iparr[1]);
                  oraspaceconfig.setLinkuse("");
                  oraspaceconfig.setAlarmvalue(90);
                  oraspaceconfig.setSms(new Integer(0)); // 0:不告警 1:告警,默认的情况是不发送短信
                  oraspaceconfig.setReportflag(new Integer(0)); // 0:不存在于报表 1:存在于报表,默认的情况是不存在于报表
                  conn = new DBManager();
                  save(oraspaceconfig);
                  // configV.add(oraspaceconfig);
                  oraspacehash.put(tip + ":" + iparr[1] + ":" + spacename, oraspaceconfig);
                }
              }
            }
          }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    // TODO Auto-generated method stub
  }