Beispiel #1
0
  @Override
  public Map<String, String> getSelectArray() {
    Map<String, String> map = new LinkedHashMap<String, String>();
    if (view == null) view = Toolkit.getToolkit().getSvdbView(this.getDesktop());
    map.put("127.0.0.1", "127.0.0.1");

    INode[] ses = view.getSe();
    for (INode se : ses) {
      map.putAll(this.getServerByNodeId(se.getSvId()));
    }
    //		return map;

    // ÅÅÐò
    ArrayList keylist = new ArrayList();
    for (String key : map.keySet()) {
      keylist.add(key);
    }
    Object[] strKeylist = keylist.toArray();
    Arrays.sort(strKeylist); // ÅÅÐò
    Map<String, String> changedMap = new LinkedHashMap<String, String>();
    for (Object key : strKeylist) {
      String value = map.get(key);
      changedMap.put(key.toString(), value);
    }
    return changedMap;
  }
Beispiel #2
0
 private Map<String, String> getServerByNodeId(String id) {
   Map<String, String> map = new LinkedHashMap<String, String>();
   INode node = view.getNode(id);
   if (node == null) return map;
   if (INode.MONITOR.equals(node.getType())) {
     return map;
   }
   if (INode.ENTITY.equals(node.getType())) {
     EntityInfo entityinfo = view.getEntityInfo(node);
     if (entityinfo.getDeviceType() != null) {
       if ("_win".equals(entityinfo.getDeviceType())
           || "_unix".equals(entityinfo.getDeviceType())) {
         map.put(
             entityinfo.getSvId(), entityinfo.getName() + "(" + entityinfo.getDeviceType() + ")");
         return map;
       }
     }
   }
   IForkNode f = (IForkNode) node;
   List<String> ids = f.getSonList();
   for (String newid : ids) {
     map.putAll(this.getServerByNodeId(newid));
   }
   return map;
 }
 public INode getSelectedNode() {
   Treeitem item = getSelectTree().getSelectedItem();
   if (item == null) return null;
   EccTreeItem itemNode = (EccTreeItem) item.getValue();
   INode node = itemNode.getValue();
   if (!node.getType().equals(INode.MONITOR)) return null;
   return node;
 }
 /**
  * 取得设置的全部id值
  *
  * @return String 形如"id1,id2,id3,"的字符串
  */
 public String getAllSelectedIds() {
   StringBuffer sb = new StringBuffer();
   for (String obj : getSelectedIds()) {
     INode node = ChartUtil.getView().getNode(obj);
     if (sb.length() > 0) sb.append(";");
     sb.append(node.getName());
   }
   if (sb.length() == 0) {
     return null;
   }
   sb.append(";");
   return sb.toString();
 }
  public static List<String> getAllMonitors2(EccTreeModel treemodel, EccTreeItem node) {
    List<String> retlist = new ArrayList<String>();

    INode inode = node.getValue();
    if (inode == null) return retlist;
    if (INode.ENTITY.equals(inode.getType())) {
      retlist.add(node.getId());
      return retlist;
    }
    for (EccTreeItem son : node.getChildRen()) {
      retlist.addAll(getAllMonitors2(treemodel, son));
    }
    return retlist;
  }
  public List<String> getAllMonitors(String monitortype, EccTreeModel treemodel, EccTreeItem node) {
    List<String> retlist = new ArrayList<String>();

    INode inode = node.getValue();
    if (inode != null && INode.ENTITY.equals(inode.getType())) {
      if (monitortype != null) {
        EntityInfo entityInfo = treemodel.getView().getEntityInfo(node.getValue());
        if (!monitortype.equals(entityInfo.getType())) {
          return retlist;
        }
      }
      retlist.add(node.getId());
      return retlist;
    }
    for (EccTreeItem son : node.getChildRen()) {
      retlist.addAll(getAllMonitors2(treemodel, son));
    }
    return retlist;
  }
  private void createStateGrid() throws Exception {
    try {
      View view = Toolkit.getToolkit().getSvdbView(getDesktop());
      INode node = this.getSelectedNode();
      if (node == null) {
        Messagebox.show(ErrorMessage.UNSELECT_MONITOR, "提示", Messagebox.OK, Messagebox.INFORMATION);
        return;
      }
      if (getBeginDatabox().getValue().after(getEndDatabox().getValue())) {
        Messagebox.show(ErrorMessage.TIME_ERROR, "提示", Messagebox.OK, Messagebox.INFORMATION);
        return;
      }
      Date begin_date = getBeginDatabox().getValue();
      Date end_date = getEndDatabox().getValue();
      getBeginLabel().setValue(Toolkit.getToolkit().formatDate(begin_date));
      getEndLabel().setValue(Toolkit.getToolkit().formatDate(end_date));
      Report report = new Report(node, begin_date, end_date);
      report.load();

      Map<Date, DstrItem> dstrMap = report.getDstr();
      if (dstrMap == null || dstrMap.size() == 0) {
        this.getBeginLabel().setValue("");
        this.getEndLabel().setValue("");
        ChartUtil.clearComponent(getStatePercentRows());
        getStatusImage().setSrc("");
        getSpectrumImage().setSrc("");
        ChartUtil.clearComponent(getStatePeriodRow());
        //				Messagebox.show("没有您要显示的数据!", "提示", Messagebox.OK,
        //						Messagebox.INFORMATION);
        return;
      }
      int ok = 0, warn = 0, error = 0, disable = 0, bad = 0;
      double size = dstrMap.size(); // 提高精度
      if (colorlist.size() > 0) colorlist.clear();
      if (stateItems.size() > 0) stateItems.clear();
      for (Date keyDate : dstrMap.keySet()) {
        DstrItem dstrItem = dstrMap.get(keyDate);
        if ("ok".equals(dstrItem.status)) {
          ok++;
          colorlist.add(MonitorType.getColor(MonitorType.OK));
        } else if ("warning".equals(dstrItem.status)) {
          warn++;
          colorlist.add(MonitorType.getColor(MonitorType.WARN));
        } else if ("error".equals(dstrItem.status)) {
          error++;
          colorlist.add(MonitorType.getColor(MonitorType.ERROR));
        } else if ("disable".equals(dstrItem.status)) {
          disable++;
          colorlist.add(MonitorType.getColor(MonitorType.DISABLE));
        } else {
          bad++;
          colorlist.add(MonitorType.getColor(MonitorType.BAD));
        }
      }
      stateBean =
          new StateBean(
              node.getSvId(),
              node.getName(),
              Toolkit.getToolkit().formatDate(begin_date),
              Toolkit.getToolkit().formatDate(end_date),
              ok / size * 100,
              warn / size * 100,
              error / size * 100,
              disable / size * 100,
              bad / size * 100);
      Row row =
          addRow(
              new Row(),
              stateBean,
              stateBean.getPercentOk(),
              stateBean.getPercentWarn(),
              stateBean.getPercentError(),
              stateBean.getPercentDisable(),
              stateBean.getPercentBad());
      ChartUtil.clearComponent(getStatePercentRows());
      getStatePercentRows().appendChild(row);
      getDesktop().getSession().setAttribute("colorlist", colorlist);
      getSpectrumImage().setSrc("/main/report/SpectrumImage?Id" + new Random().nextDouble());
      PieDataset dataSet = createDataset(stateBean);
      Image image = ChartUtil.create3DPieChart(node.getName(), dataSet, 600, 300);
      getStatusImage().setSrc(image.getSrc());

      int index = 0;
      List<Date> aliasKey = new ArrayList<Date>(dstrMap.keySet());
      ChartUtil.clearComponent(getStatePeriodRow());
      while (index < size) {
        Date startTime = null;
        Date endTime = null;
        String status = null;
        int count = 0;
        for (; index < size; index++) {
          DstrItem dstrItem = dstrMap.get(aliasKey.get(index));
          //					if (!"ok".equals(dstrItem.status) && !"error".equals(dstrItem.status))	continue;
          if (status == null) status = dstrItem.status;
          if (!status.equals(dstrItem.status)) break;
          if (startTime == null) startTime = aliasKey.get(index);
          count++;
          endTime = aliasKey.get(index);
        }
        if (startTime == null || endTime == null) {
          Row blankRow = new Row();
          blankRow.appendChild(new Label("无数据!"));
          getStatePeriodRow().appendChild(blankRow);
          continue;
        }
        String strTime = subtract2Date(startTime, endTime);
        StateItem sitem =
            new StateItem(
                Toolkit.getToolkit().formatDate(startTime), status, String.valueOf(count), strTime);
        stateItems.add(sitem);
        Row generatetime =
            addRow(
                new Row(),
                null,
                sitem.getBeginTime(),
                ChartUtil.getImage(sitem.getStatus()),
                sitem.getCount(),
                sitem.getPersistTime());
        getStatePeriodRow().appendChild(generatetime);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }