コード例 #1
0
  private void changeWebManage() {
    WebConfig vo = new WebConfig();
    try {
      int monflag = getParaIntValue("value");
      WebConfigDao configdao = new WebConfigDao();
      try {
        vo = (WebConfig) configdao.findByID(getParaValue("id"));
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        configdao.close();
      }

      vo.setFlag(monflag);
      configdao = new WebConfigDao();
      try {
        configdao.update(vo);
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        configdao.close();
      }

      Web web = (Web) PollingEngine.getInstance().getWebByID(vo.getId());
      web.setFlag(monflag);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
  /**
   * 根据 webConfig 来组装 中间件
   *
   * @param webConfig
   * @return
   */
  public MonitorServiceDTO getMonitorServiceDTOByWeb(WebConfig webConfig) {

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = simpleDateFormat.format(new Date());

    String starttime = date + " 00:00:00";
    String totime = date + " 23:59:59";

    int id = webConfig.getId();
    String alias = webConfig.getAlias();
    String ipAddress = webConfig.getIpAddress();
    String category = "web";

    Node webNode = PollingEngine.getInstance().getWebByID(id);

    int status = 0;
    try {
      status = webNode.getStatus();
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Hashtable eventListSummary = new Hashtable();

    String generalAlarm = "0"; // 普通告警数  默认为 0
    String urgentAlarm = "0"; // 严重告警数  默认为 0
    String seriousAlarm = "0"; // 紧急告警数  默认为 0

    EventListDao eventListDao = new EventListDao();
    try {
      generalAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='1' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      urgentAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='2' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
      seriousAlarm =
          eventListDao.getCountByWhere(
              " where nodeid='"
                  + id
                  + "'"
                  + " and level1='3' and recordtime>='"
                  + starttime
                  + "' and recordtime<='"
                  + totime
                  + "'");
    } catch (RuntimeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      eventListDao.close();
    }
    eventListSummary.put("generalAlarm", generalAlarm);
    eventListSummary.put("urgentAlarm", urgentAlarm);
    eventListSummary.put("seriousAlarm", seriousAlarm);

    String monflag = "否";
    if (webConfig.getFlag() == 1) {
      monflag = "是";
    }

    MonitorServiceDTO monitorServiceDTO = new MonitorServiceDTO();
    monitorServiceDTO.setId(id);
    monitorServiceDTO.setStatus(String.valueOf(status));
    monitorServiceDTO.setAlias(alias);
    monitorServiceDTO.setIpAddress(ipAddress);
    monitorServiceDTO.setPingValue("");
    monitorServiceDTO.setCategory(category);
    monitorServiceDTO.setEventListSummary(eventListSummary);
    monitorServiceDTO.setMonflag(monflag);
    return monitorServiceDTO;
  }