コード例 #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
  /** 更新所有info项和image项 */
  public void updateInfo(boolean isCustom) {
    I_HostLastCollectData hostlastmanager = new HostLastCollectDataManager();
    List list = nodes.getChildren();
    for (int i = 0; i < list.size(); i++) {
      Element eleNode = (Element) list.get(i);
      int id = Integer.valueOf(eleNode.getChildText("id")).intValue();
      int direction = Integer.valueOf(eleNode.getChildText("direction")).intValue();
      // Hashtable ipAllData = (Hashtable)ShareData.getSharedata().get(ipaddress);

      Vector vector = new Vector();
      String[] netInterfaceItem = {
        "index", "ifDescr", "ifSpeed", "ifOperStatus", "OutBandwidthUtilHdx", "InBandwidthUtilHdx"
      };
      try {
        vector = hostlastmanager.getInterface_share(ipaddress, netInterfaceItem, "index", "", "");
      } catch (Exception e) {
        e.printStackTrace();
      }
      SysLogger.info("######################################");
      SysLogger.info("######### " + ipaddress + "   ##############");
      SysLogger.info("######################################");
      if (vector != null && vector.size() > 0) {
        PortconfigDao dao = new PortconfigDao();
        try {
          for (int m = 0; m < vector.size(); m++) {
            String[] strs = (String[]) vector.get(m);
            String ifname = strs[1];
            String index = strs[0];
            String OutBandwidthUtilHdx = strs[4];
            String InBandwidthUtilHdx = strs[5];
            String portuse = "";
            Portconfig portconfig = null;
            try {
              portconfig = dao.getPanelByipandindex(ipaddress, index);
            } catch (Exception e) {

            }
            if (portconfig != null
                && portconfig.getLinkuse() != null
                && portconfig.getLinkuse().trim().length() > 0) {
              portuse = portconfig.getLinkuse();
            }
            if (Integer.parseInt(index) == id) {
              // 当前端口
              if (direction == 1) {
                // 向上方向的端口
                if (strs[3].equalsIgnoreCase("up")) {
                  // 端口启动
                  SysLogger.info(PanelNodeHelper.getUpUpImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getUpUpImage(1));
                } else {
                  // 端口未启动
                  SysLogger.info(PanelNodeHelper.getUpDownImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getUpDownImage(1));
                }

              } else {
                // 向下方向的端口
                if (strs[3].equalsIgnoreCase("up")) {
                  // 端口启动
                  SysLogger.info(PanelNodeHelper.getDownUpImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getDownUpImage(1));
                } else {
                  // 端口未启动
                  SysLogger.info(PanelNodeHelper.getDownDownImage(1));
                  eleNode.getChild("img").setText(PanelNodeHelper.getDownDownImage(1));
                }
              }

              eleNode.getChild("alias").setText(ifname);
              eleNode.getChild("ip").setText(ipaddress);

              StringBuffer msg = new StringBuffer(200);
              msg.append("<font color='green'>索引:");
              msg.append(id);
              msg.append("</font><br>");

              msg.append("描述:");
              msg.append(ifname);
              msg.append("<br>");

              msg.append("端口应用:");
              msg.append(portuse);
              msg.append("<br>");

              msg.append("入口流速:");
              msg.append(InBandwidthUtilHdx);
              msg.append("<br>");

              msg.append("出口流速:");
              msg.append(OutBandwidthUtilHdx);
              msg.append("<br>");

              SysLogger.info(msg.toString());
              eleNode.getChild("info").setText(msg.toString());
              eleNode.getChild("menu").setText(PanelNodeHelper.getMenuItem(index, ipaddress));
            }
          }
        } catch (Exception e) {

        } finally {
          dao.close();
        }
      }
      // nodes.addContent(i, eleNode);
    }

    if (isCustom) {
      writeXml();
      return;
    }
    writeXml();
  }
コード例 #3
0
  /** @author nielin modify at 2010-01-08 */
  public int writeXml(int flag) {
    int done = 0;
    // 需要做分布式判断
    String runmodel = PollingEngine.getCollectwebflag();
    try {
      I_HostLastCollectData hostlastmanager = new HostLastCollectDataManager();
      Hashtable ipAllData = (Hashtable) ShareData.getSharedata().get(ipaddress);

      Vector vector = new Vector();
      String[] netInterfaceItem = {
        "index",
        "ifDescr",
        "ifSpeed",
        "ifAdminStatus",
        "ifOperStatus",
        "OutBandwidthUtilHdx",
        "InBandwidthUtilHdx"
      };
      try {
        if ("0".equals(runmodel)) {
          // 采集与访问是集成模式
          vector = hostlastmanager.getInterface_share(ipaddress, netInterfaceItem, "index", "", "");
        } else {
          // 采集与访问是分离模式
          vector = hostlastmanager.getInterface(ipaddress, netInterfaceItem, "index", "", "");
        }
      } catch (Exception e) {
        e.printStackTrace();
        return done;
      }
      try {
        _fis =
            new FileInputStream(
                ResourceCenter.getInstance().getSysPath()
                    + "panel/model/"
                    + oid
                    + "_"
                    + imageType
                    + ".jsp");
      } catch (Exception e) {
        e.printStackTrace();
        _fis.close();
        return done;
      }
      _fis.skip(headBytes.getBytes().length);
      _builder = new SAXBuilder();
      _doc = _builder.build(_fis);
      _root = _doc.getRootElement();
      _nodes = _root.getChild("nodes");

      List list = _nodes.getChildren();

      PortconfigDao dao = new PortconfigDao();

      try {

        for (int i = 0; i < list.size(); i++) {
          Element eleNode = (Element) list.get(i);
          if (eleNode.getChildText("index") == null) break;
          int index = Integer.valueOf(eleNode.getChildText("index")).intValue();
          String x = eleNode.getChildText("x");
          String y = eleNode.getChildText("y");
          String img = eleNode.getChildText("img");
          String direction = eleNode.getChildText("direction");
          String ifname = "";
          String OutBandwidthUtilHdx = "0";
          String InBandwidthUtilHdx = "0";
          String portuse = "";
          if (vector != null && vector.size() > 0) {
            for (int m = 0; m < vector.size(); m++) {
              String[] strs = (String[]) vector.get(m);
              String _ifname = strs[1];
              String _index = strs[0];
              String opstatus = strs[4];
              OutBandwidthUtilHdx = strs[5];
              InBandwidthUtilHdx = strs[6];

              Portconfig portconfig = null;
              try {
                portconfig = dao.getPanelByipandindex(ipaddress, index + "");
              } catch (Exception e) {

              }
              if (portconfig != null
                  && portconfig.getLinkuse() != null
                  && portconfig.getLinkuse().trim().length() > 0) {
                portuse = portconfig.getLinkuse();
              }

              // SysLogger.info(ipaddress+"====ifOperStatus====="+strs[4]);
              if (Integer.parseInt(_index) == index) {
                ifname = _ifname;
                if ("down".equalsIgnoreCase(opstatus)) {
                  // DOWN
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_down_gray.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_down_gray.gif";
                  }
                } else {
                  // UP
                  if ("1".equalsIgnoreCase(direction)) {
                    // 向上的端口
                    img = "image/up_up_green.gif";
                  } else {
                    // 向下的端口
                    img = "image/down_up_green.gif";
                  }
                }
                break;
              }
            }
          }
          addNode(
              index + "",
              InBandwidthUtilHdx,
              OutBandwidthUtilHdx,
              img,
              ipaddress,
              ifname,
              portuse,
              x,
              y);
        }

      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        dao.close();
      }

      Format format = Format.getCompactFormat();
      format.setEncoding("GB2312");
      format.setIndent("	");
      serializer = new XMLOutputter(format);
      // SysLogger.info("path==="+fullPath);
      fos = new FileOutputStream(fullPath);
      fos.write(headBytes.getBytes());
      serializer.output(doc, fos);
      fos.close();
      done = 1;
    } catch (Exception e) {
      done = 0;
      e.printStackTrace();
      SysLogger.error("Error in XmlOperator.close()", e);
    }
    return done;
  }