コード例 #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
ファイル: Host.java プロジェクト: pei-han/sxydafunms726
  /** 对IP_Net_To_Media进行探测 */
  private void doIPNetProbe() {
    if (DiscoverEngine.getInstance().getStopStatus() == 1) return;
    List ipNetTable =
        SnmpUtil.getInstance().getIpNetToMediaTable(this.getIpAddress(), this.getCommunity());

    if (ipNetTable == null || ipNetTable.size() == 0) // important
    {
      setDiscovered(true);
      return;
    }
    ipTotal = ipNetTable.size();
    int threadTotal = 0; // 线程总数
    SysLogger.info("PER_THREAD_IP===" + PER_THREAD_IP);
    if (ipTotal % PER_THREAD_IP == 0) // 每个线程对N个ip进行探测
    threadTotal = ipTotal / PER_THREAD_IP;
    else threadTotal = ipTotal / PER_THREAD_IP + 1;

    IPNetProbeThread probeThread = null;
    for (int i = 0; i < threadTotal; i++) {
      if (i == threadTotal - 1)
        probeThread = new IPNetProbeThread(this, ipNetTable.subList(i * PER_THREAD_IP, ipTotal));
      else
        probeThread =
            new IPNetProbeThread(
                this, ipNetTable.subList(i * PER_THREAD_IP, (i + 1) * PER_THREAD_IP));
      DiscoverEngine.getInstance().addThread(probeThread);
    }
  }
コード例 #3
0
  public void run() {
    if (DiscoverEngine.getInstance().getStopStatus() == 1) return;
    snmp = SnmpUtil.getInstance();
    SysLogger.info("开始分析设备" + node.getIpAddress() + "的地址转发表");
    Set shieldList = DiscoverResource.getInstance().getShieldSet();
    List netshieldList = DiscoverResource.getInstance().getNetshieldList();
    List netincludeList = DiscoverResource.getInstance().getNetincludeList();
    IfEntity ifEntity = null;
    IfEntity endifEntity = null;

    // 生成线程池
    ThreadPool threadPool = new ThreadPool(addressList.size());

    for (int i = 0; i < addressList.size(); i++) {
      // ###################################
      // 若不需要服务器,则不进行交换机的ARP表采集
      // if(1==1)continue;
      // ###################################
      try {
        // node.updateCount(2);
        IpAddress ipAddr = (IpAddress) addressList.get(i);
        threadPool.runTask(NetMediThread.createTask(ipAddr, node));
        // SysLogger.info("在"+node.getIpAddress()+"的地址转发表发现IP "+ipAddr.getIpAddress()+",开始分析");
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    } // end_for
    // 关闭线程池并等待所有任务完成
    threadPool.join();
    threadPool.close();
    threadPool = null;

    DiscoverEngine.getInstance().addDiscoverdcount();
    snmp = null;
    setCompleted(true);
  } // end_run
コード例 #4
0
ファイル: Host.java プロジェクト: pei-han/sxydafunms726
 /** 对IP_Rouer_Table进行探测 */
 private void doIPRouterProbe() {
   if (DiscoverEngine.getInstance().getStopStatus() == 1) return;
   DiscoverEngine.getInstance().addThread(new IPRouterProbeThread(this));
 }