コード例 #1
0
 public void analsysNDPHost(Host node, Host host) {
   if (host.getNdpHash() == null)
     host.setNdpHash(snmp.getNDPTable(host.getIpAddress(), host.getCommunity()));
   // 判断该NDP中是否包含node的MAC地址,若包含,则说明node是跟该设备直接连接关系
   Hashtable hostNDPHash = host.getNdpHash();
   if (host.getMac() == null) {
     String descr = (String) hostNDPHash.get(node.getMac());
     IfEntity nodeIfEntity = node.getIfEntityByDesc(descr);
     Link link = new Link();
     link.setStartId(node.getId());
     link.setStartIndex(nodeIfEntity.getIndex());
     link.setStartIp(node.getIpAddress());
     link.setStartPhysAddress(node.getMac()); // 记录下起点的mac
     link.setStartDescr(descr);
     link.setEndIp(host.getIpAddress());
     DiscoverEngine.getInstance().addHost(host, link);
   } else {
     if (node.getNdpHash() != null) {
       if (node.getNdpHash().containsKey(host.getMac())) {
         String hostdesc = (String) node.getNdpHash().get(host.getMac());
         String descr = (String) hostNDPHash.get(node.getMac());
         IfEntity nodeIfEntity = node.getIfEntityByDesc(descr);
         IfEntity hostIfEntity = host.getIfEntityByDesc(hostdesc);
         Link link = new Link();
         link.setStartId(node.getId());
         link.setStartIndex(nodeIfEntity.getIndex());
         link.setStartIp(node.getIpAddress());
         link.setStartPhysAddress(node.getMac()); // 记录下起点的mac
         link.setStartDescr(descr);
         link.setEndIndex(hostIfEntity.getIndex());
         link.setEndIp(host.getIpAddress());
         link.setEndPhysAddress(hostIfEntity.getPhysAddress());
         link.setEndDescr(hostdesc);
         DiscoverEngine.getInstance().addHost(host, link);
       } else {
         String descr = (String) hostNDPHash.get(node.getMac());
         IfEntity nodeIfEntity = node.getIfEntityByDesc(descr);
         Link link = new Link();
         link.setStartId(node.getId());
         link.setStartIndex(nodeIfEntity.getIndex());
         link.setStartIp(node.getIpAddress());
         link.setStartPhysAddress(node.getMac()); // 记录下起点的mac
         link.setStartDescr(descr);
         link.setEndIp(host.getIpAddress());
         DiscoverEngine.getInstance().addHost(host, link);
       }
     } else {
       String descr = (String) hostNDPHash.get(node.getMac());
       IfEntity nodeIfEntity = node.getIfEntityByDesc(descr);
       Link link = new Link();
       link.setStartId(node.getId());
       link.setStartIndex(nodeIfEntity.getIndex());
       link.setStartIp(node.getIpAddress());
       link.setStartPhysAddress(node.getMac()); // 记录下起点的mac
       link.setStartDescr(descr);
       link.setEndIp(host.getIpAddress());
       DiscoverEngine.getInstance().addHost(host, link);
     }
   }
 }
コード例 #2
0
 /*
  * 查询唯一IP列表
  * auth@hukelei
  * date 2010-01-21
  *
  */
 public Hashtable getDistinctIp() {
   Hashtable returnHash = new Hashtable();
   Session session = null;
   Hashtable retValue = new Hashtable();
   try {
     rs = conn.executeQuery("select distinct(ipaddress) from system_oraspaceconf");
     while (rs.next()) returnHash.put(rs.getString("ipaddress"), rs.getString("ipaddress"));
   } catch (Exception e) {
     e.printStackTrace();
   }
   return returnHash;
 }
コード例 #3
0
 /*
  * 根据IP和是否要显示于日报表的标志位查询
  *
  */
 public Hashtable getByAlarmflag(Integer smsflag) {
   List list = new ArrayList();
   Session session = null;
   Hashtable retValue = new Hashtable();
   try {
     rs =
         conn.executeQuery(
             "select * from system_oraspaceconf where sms=" + smsflag + " order by ipaddress");
     // Query query=session.createQuery("from Oraspaceconfig oraspaceconfig where
     // oraspaceconfig.sms="+smsflag+" order by oraspaceconfig.ipaddress");
     while (rs.next()) list.add(loadFromRS(rs));
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         Oraspaceconfig oraspaceconfig = (Oraspaceconfig) list.get(i);
         String ipaddr = oraspaceconfig.getIpaddress();
         String[] iparry = ipaddr.split(":");
         IpTranslation tranfer = new IpTranslation();
         String[] tip = tranfer.getIpFromHex(iparry[0]);
         retValue.put(
             tip[0]
                 + "."
                 + tip[1]
                 + "."
                 + tip[2]
                 + "."
                 + tip[3]
                 + ":"
                 + iparry[1]
                 + ":"
                 + oraspaceconfig.getSpacename(),
             oraspaceconfig);
         // SysLogger.info(tip[0]+"."+tip[1]+"."+tip[2]+"."+tip[3]+":"+iparry[1]+":"+oraspaceconfig.getSpacename()+"===="+oraspaceconfig.getSpacename());
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   // TODO Auto-generated method stub
   return retValue;
 }
コード例 #4
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
  }