/**
   * DB서비스 모니터링를 수행한다.
   *
   * @param
   * @return
   * @throws Exception
   */
  public void monitorDb() throws Exception {
    // 모니터링 대상 정보 읽어들이기~~~
    List<DbMntrng> targetList = null;
    DbMntrng searchVO = new DbMntrng();
    // 모니터링 대상 검색 조건 초기화
    searchVO.setPageIndex(1);
    searchVO.setFirstIndex(0);
    searchVO.setRecordCountPerPage(RECORD_COUNT_PER_PAGE);
    targetList = dbMntrngService.selectDbMntrngList(searchVO);
    LOGGER.debug("조회조건 {}", searchVO);
    LOGGER.debug("Result 건수 : {}", targetList.size());
    // 서비스체크 함수 호출.
    Iterator<DbMntrng> iter = targetList.iterator();
    DbMntrng target = null;
    DbMntrngResult result = null;
    DbMntrngLog dbMntrngLog = null;
    String dmMntrngLogId = null;
    while (iter.hasNext()) {
      target = iter.next();
      LOGGER.debug("Data : {}", target);
      // 서비스 체크 수행.
      result = DbMntrngChecker.check(context, target.getDataSourcNm(), target.getCeckSql());

      // 대상테이블에 DB에 결과값 저장
      if (result.isNrmltAt()) {
        target.setMntrngSttus("01");
      } else {
        target.setMntrngSttus("02");
      }
      target.setLastUpdusrId("SYSTEM");
      dbMntrngService.updateDbMntrng(target);
      // 로그테이블 추가저장.
      dbMntrngLog = new DbMntrngLog();
      dmMntrngLogId = idgenService.getNextStringId();
      dbMntrngLog.setLogId(dmMntrngLogId);
      dbMntrngLog.setDataSourcNm(target.getDataSourcNm());
      dbMntrngLog.setServerNm(target.getServerNm());
      dbMntrngLog.setDbmsKind(target.getDbmsKind());
      dbMntrngLog.setCeckSql(target.getCeckSql());
      dbMntrngLog.setMngrNm(target.getMngrNm());
      dbMntrngLog.setMngrEmailAddr(target.getMngrEmailAddr());
      dbMntrngLog.setMntrngSttus(target.getMntrngSttus());
      dbMntrngLog.setFrstRegisterId("SYSTEM");
      dbMntrngLog.setLastUpdusrId("SYSTEM");
      if (result.getCause() != null) {
        LOGGER.debug("에러메시지: {}", result.getCause().getMessage());

        if (result.getCause().getMessage() != null) {
          dbMntrngLog.setLogInfo(result.getCause().getMessage());
        } else {
          dbMntrngLog.setLogInfo("");
        }

      } else {
        dbMntrngLog.setLogInfo("");
      }
      dbMntrngService.insertDbMntrngLog(dbMntrngLog);

      // 모니터링시각을 가져오기위해 로그정보를 가져온다.
      dbMntrngLog = dbMntrngService.selectDbMntrngLog(dbMntrngLog);
      LOGGER.debug("DB서비스로그 Data : {}", dbMntrngLog);
      // email 전송.
      if (!result.isNrmltAt()) {
        sendEmail(dbMntrngLog);
      }
    }
  }
Пример #2
0
  /**
   * DB서비스 모니터링를 수행한다.
   *
   * @param
   * @return
   * @throws Exception
   */
  public int monitorDb() throws Exception {
    int batchResult = 0;

    // 모니터링 대상 정보 읽어들이기~~~
    List<EgovMap> targetList = null;
    DbMntrngVO dbMntrngVO = new DbMntrngVO();
    // 모니터링 대상 검색 조건 초기화
    dbMntrngVO.getSearchVO().setPageIndex(1);
    dbMntrngVO.getSearchVO().setFirstIndex(0);
    dbMntrngVO.getSearchVO().setRecordPerPage(RECORD_COUNT_PER_PAGE);
    targetList = dbMntrngService.selectDbMntrngList(dbMntrngVO);
    if (LOG.isDebugEnabled()) {
      LOG.debug("조회조건 " + dbMntrngVO);
      LOG.debug("Result 건수 : " + targetList.size());
    }
    // 서비스체크 함수 호출.
    Iterator<EgovMap> iter = targetList.iterator();
    EgovMap target = null;
    DbMntrngResult result = null;
    DbMntrngVO dbMntrng = null;
    DbMntrngLogVO dbMntrngLog = null;
    while (iter.hasNext()) {
      target = iter.next();
      if (LOG.isDebugEnabled()) {
        LOG.debug("Data : " + target);
      }
      dbMntrng = new DbMntrngVO();
      dbMntrng.setDataSourcNm((String) target.get("dataSourcNm"));
      dbMntrng.setServerNm((String) target.get("serverNm"));
      dbMntrng.setDbmsKind((String) target.get("dbmsKind"));
      dbMntrng.setCeckSql((String) target.get("ceckSql"));
      dbMntrng.setMngrNm((String) target.get("mngrNm"));
      dbMntrng.setMngrEmailAddr((String) target.get("mngrEmailAddr"));
      dbMntrng.setMntrngSttus((String) target.get("mntrngSttus"));

      // 서비스 체크 수행.
      result = DbMntrngChecker.check(dataSource, dbMntrng.getDataSourcNm(), dbMntrng.getCeckSql());

      // 대상테이블에 DB에 결과값 저장
      if (result.isNrmltAt()) {
        dbMntrng.setMntrngSttus("01");
      } else {
        dbMntrng.setMntrngSttus("02");
      }
      dbMntrng.setLastUpdusrId("SYSTEM");
      dbMntrngService.updateDbMntrng(dbMntrng);

      // 로그테이블 추가저장.
      dbMntrngLog = new DbMntrngLogVO();
      dbMntrngLog.setLogId(dbMntrngLogIdGnrService.getNextStringId());
      dbMntrngLog.setDataSourcNm(dbMntrng.getDataSourcNm());
      dbMntrngLog.setServerNm(dbMntrng.getServerNm());
      dbMntrngLog.setDbmsKind(dbMntrng.getDbmsKind());
      dbMntrngLog.setCeckSql(dbMntrng.getCeckSql());
      dbMntrngLog.setMngrNm(dbMntrng.getMngrNm());
      dbMntrngLog.setMngrEmailAddr(dbMntrng.getMngrEmailAddr());
      dbMntrngLog.setMntrngSttus(dbMntrng.getMntrngSttus());
      dbMntrngLog.setFrstRegisterId(dbMntrng.getLastUpdusrId());
      if (result.getCause() != null) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("에러메시지: " + result.getCause().getMessage());
        }

        if (result.getCause().getMessage() != null) {
          dbMntrngLog.setLogInfo(result.getCause().getMessage());
        } else {
          dbMntrngLog.setLogInfo("");
        }

      } else {
        dbMntrngLog.setLogInfo("");
      }
      dbMntrngService.insertDbMntrngLog(dbMntrngLog);

      // 모니터링시각을 가져오기위해 로그정보를 가져온다.
      dbMntrngLog = dbMntrngService.selectDbMntrngLog(dbMntrngLog);
      if (LOG.isDebugEnabled()) {
        LOG.debug("DB서비스로그 Data : " + dbMntrngLog);
      }
      // email 전송.
      if (!result.isNrmltAt()) {
        batchResult = -1;
        sendEmail(dbMntrngLog);
      }
    }
    return batchResult;
  }