コード例 #1
0
  public String reportDayList() {
    StringBuffer s = new StringBuffer();
    User current_user = (User) session.getAttribute(SessionConstant.CURRENT_USER);
    if (current_user.getBusinessids() != null) {
      if (current_user.getBusinessids() != "-1") {
        String[] bids = current_user.getBusinessids().split(",");
        if (bids.length > 0) {
          for (int ii = 0; ii < bids.length; ii++) {
            if (bids[ii].trim().length() > 0) {
              s.append(" bid like '%").append(bids[ii]).append("%' ");
              if (ii != bids.length - 1) s.append(" or ");
            }
          }
        }
      }
    }
    // InterfaceTempDao interfaceDao = new InterfaceTempDao();
    List list = new ArrayList();
    HostNodeDao dao = new HostNodeDao();
    list = dao.loadNetworkByBid(4, current_user.getBusinessids());

    List interfaceList = new ArrayList();
    PortconfigDao portconfigDao = new PortconfigDao();
    try {
      interfaceList = portconfigDao.getAllBySms();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      portconfigDao.close();
    }

    request.setAttribute("list", list);
    request.setAttribute("interfaceList", interfaceList);
    return "/capreport/comprehensive/compreReportDay.jsp";
  }
コード例 #2
0
  public void run() {
    try {
      HostNodeDao nodeDao = new HostNodeDao();
      // 得到被监视的防火墙设备
      List nodeList = nodeDao.loadNetwork(8);
      for (int i = 0; i < nodeList.size(); i++) {
        HostNode node = (HostNode) nodeList.get(i);
      }
      Vector vector = null;
      int numTasks = nodeList.size();
      int numThreads = 200;

      try {
        List numList = new ArrayList();
        TaskXml taskxml = new TaskXml();
        numList = taskxml.ListXml();
        for (int i = 0; i < numList.size(); i++) {
          Task task = new Task();
          BeanUtils.copyProperties(task, numList.get(i));
          if (task.getTaskname().equals("netthreadnum")) {
            numThreads = task.getPolltime().intValue();
          }
        }

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

      // 生成线程池
      ThreadPool threadPool = null;
      if (nodeList != null && nodeList.size() > 0) {
        threadPool = new ThreadPool(nodeList.size());
        // 运行任务
        for (int i = 0; i < nodeList.size(); i++) {
          threadPool.runTask(createTask((HostNode) nodeList.get(i)));
        }
        // 关闭线程池并等待所有任务完成
        threadPool.join();
        threadPool.close();
      }
      threadPool = null;

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      SysLogger.info("********Firewall Thread Count : " + Thread.activeCount());
    }
  }
コード例 #3
0
  private void importOnePage(IVPage page) {
    visio.IVShapes shapes = page.shapes();
    visio.IVShape shape = null;
    if (shapes.count() > 0) {
      String pattern =
          "(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])";
      Pattern p = Pattern.compile(pattern);
      Matcher m = null;
      Set<String> allDevIPs = new HashSet<String>();
      for (int i = 1; i <= shapes.count(); i++) {
        shape = shapes.item(i);
        m = p.matcher(shape.text());
        if (m.find()) {
          allDevIPs.add(m.group());
        }
      }

      visio.IVConnects connects = page.connects();
      // System.out.println(connects.count());

      if (connects.count() > 0) {
        List<String> list = new ArrayList<String>();
        for (int i = 1; i <= connects.count(); i++) {
          visio.IVConnect connect = connects.item(i);
          list.add(connect.fromSheet().text() + "_" + connect.toSheet().text());
          if (list.size() == 2) {
            String startPoint = list.get(0); // 起点Gi1/1-Fa0/1_192.168.1.1
            String endPoint = list.get(1); // 终点
            // Gi1/1-Fa0/1_192.168.1.2
            String[] intIP1 = startPoint.split("_"); // Gi1/1-Fa0/1,
            // 192.168.1.1

            String intsStr1 = intIP1[0]; // Gi1/1-Fa0/1
            String startIP = intIP1[1]; // 192.168.1.1
            // startIP = Regex.Match(startIP, pattern).ToString();
            m = p.matcher(startIP);
            if (m.find()) {
              startIP = m.group();
            }
            if (startIP == "") {
              list.clear();
              continue;
            }

            String[] intIP2 = endPoint.split("_"); // Gi1/1-Fa0/1,
            // 192.168.1.2
            String intsStr2 = intIP2[0]; // Gi1/1-Fa0/1
            String endIP = intIP2[1]; // 192.168.1.2
            // endIP = Regex.Match(endIP, pattern).ToString();
            m = p.matcher(endIP);
            if (m.find()) {
              endIP = m.group();
            }
            if (endIP == "") {
              list.clear();
              continue;
            }

            String startInt = "", endInt = "";

            if (intsStr1.equals(intsStr2)) // 按理说 这个if是多余的
            {
              // MySQLCommand comm = null;
              // /接口连接信息拆分成两部分,分别转换成全拼
              String[] ints = intsStr1.split("-");
              startInt = ints[0]; // Gi1/1(n)
              String startIndex = "", endIndex = ""; // 端口索引号
              String[] intstrIndex = split(startInt);

              startInt = intstrIndex[0]; // parseIntface(startInt);
              startIndex = intstrIndex[1];

              endInt = ints[1]; // Fa
              //								endInt = parseIntface(endInt);
              intstrIndex = split(endInt);
              endInt = intstrIndex[0]; // parseIntface(startInt);
              endIndex = intstrIndex[1];

              // /计算设备id
              HostNodeDao dao = new HostNodeDao();
              int startNodeID = 0, endNodeID = 0;
              startNodeID = dao.getNodeID(startIP);
              HostNode node = new HostNode();
              if (dao.getCountByIpaddress(startIP) == 0) {
                node.setId(startNodeID);
                node.setIpAddress(startIP);
                node.setSysName(startIP);
                node.setCommunity(startIP);
                node.setWriteCommunity(startIP);
                int _startIP = Integer.parseInt(startIP);
                node.setSnmpversion(_startIP);
                node.setBid(startIP);
                node.setCollecttype(_startIP);
                node.setAlias(startIP);
                dao.save(node);
              }
              dao = new HostNodeDao();
              endNodeID = dao.getNodeID(endIP);
              if (dao.getCountByIpaddress(endIP) == 0) {
                node.setId(endNodeID);
                node.setIpAddress(endIP);
                node.setSysName(endIP);
                node.setAlias(endIP);
                dao.save(node);
              }
              allDevIPs.remove(startIP);
              allDevIPs.remove(endIP);

              LinkDao linkDao = new LinkDao();
              boolean isLinkExists = linkDao.linkExists2(startNodeID, startInt, endNodeID, endInt);
              if (!isLinkExists) {
                Link vo = new Link();
                vo.setStartId(startNodeID);
                vo.setStartIp(startIP);
                vo.setStartDescr(startInt);
                vo.setStartIndex(startIndex);
                vo.setEndId(endNodeID);
                vo.setEndIp(endIP);
                vo.setEndDescr(endInt);
                vo.setEndIndex(endIndex);
                vo.setLinkName(startIP + "_" + startIndex + "/" + endIP + "_" + endIndex);
                linkDao.saveLinkOnly(vo);
              }
            }
            list.clear();
          }
        }
      }
      if (allDevIPs.size() > 0) {
        HostNode node = new HostNode();
        for (String ipaddress : allDevIPs) {
          HostNodeDao dao = new HostNodeDao();
          int nodeID = dao.getNodeID(ipaddress);
          if (null == dao.findByIpaddress(ipaddress)) {
            node.setId(nodeID);
            node.setIpAddress(ipaddress);
            node.setSysName(ipaddress);
            node.setAlias(ipaddress);
            dao.save(node);
          }
        }
      }
    }
  }