|
1 | | -package root.applications; |
2 | | - |
3 | | -import java.util.List; |
4 | | - |
5 | | -import root.common.database.contracts.AbstractDatabase; |
6 | | -import root.common.database.implement.JdbcDatabase; |
7 | | -import root.common.server.implement.JschServer; |
8 | | -import root.core.batch.DBCheckBatch; |
9 | | -import root.core.batch.ServerCheckBatch; |
10 | | -import root.core.domain.AlertLogCommand; |
11 | | -import root.core.domain.AlertLogCommandPeriod; |
12 | | -import root.core.domain.JdbcConnectionInfo; |
13 | | -import root.core.domain.JschConnectionInfo; |
14 | | -import root.core.repository.constracts.DBCheckRepository; |
15 | | -import root.core.repository.constracts.ServerCheckRepository; |
16 | | -import root.core.repository.implement.DBCheckRepositoryImpl; |
17 | | -import root.core.repository.implement.ReportFileRepo; |
18 | | -import root.core.repository.implement.ServerCheckRepositoryImpl; |
19 | | -import root.core.usecase.constracts.DBCheckUsecase; |
20 | | -import root.core.usecase.constracts.ServerCheckUsecase; |
21 | | -import root.core.usecase.implement.DBCheckUsecaseImpl; |
22 | | -import root.core.usecase.implement.ServerCheckUsecaseImpl; |
23 | | -import root.utils.ConsoleUtils; |
24 | | -import root.utils.DateUtils; |
25 | | -import root.utils.PropertiesUtils; |
26 | | - |
27 | | -public class Application { |
28 | | - |
29 | | - public static void main(String[] args) { |
30 | | - try { |
31 | | - String propertiesFilePath = ".\\config\\application.properties"; |
32 | | - |
33 | | - try { |
34 | | - PropertiesUtils.loadCombinedConfiguration(); |
35 | | - String lastUsePropertiesFile = PropertiesUtils.combinedConfig.getString("filepath.config.lastuse"); |
36 | | - PropertiesUtils.loadAppConfiguration(lastUsePropertiesFile, "connInfoConfig"); |
37 | | - PropertiesUtils.loadAppConfiguration(propertiesFilePath); |
38 | | - PropertiesUtils.loadCombinedConfiguration(); |
39 | | - PropertiesUtils.loadAppConfiguration(".\\config\\connectioninfo\\test.properties", "connInfoConfig"); |
40 | | - }catch(Exception e) { |
41 | | - System.out.println("configuration loading error\n"+e+"\n"); |
42 | | - return; |
43 | | - } |
44 | | - |
45 | | - String dbMonitoring = PropertiesUtils.propConfig.getString("monitoring.db"); |
46 | | - String serverMonitoring = PropertiesUtils.propConfig.getString("monitoring.server"); |
47 | | - |
48 | | - if("on".equals(dbMonitoring)) { |
49 | | - dbMonitoring(); |
50 | | - } |
51 | | - |
52 | | - if("on".equals(serverMonitoring)) { |
53 | | - // serverMonitoring(); |
54 | | - } |
55 | | - |
56 | | - } catch (Exception e) { |
57 | | - e.printStackTrace(); |
58 | | - } |
59 | | - |
60 | | - System.out.println("END"); |
61 | | - } |
62 | | - |
63 | | - public static void dbMonitoring() { |
64 | | - System.out.println("\n=================================================================================================================================="); |
65 | | - System.out.println(ConsoleUtils.BACKGROUND_CYAN + "※ DB Monitoring을 시작합니다." + ConsoleUtils.RESET); |
66 | | - System.out.println("==================================================================================================================================\n"); |
67 | | - |
68 | | - // DB Usage Check |
69 | | - List<JdbcConnectionInfo> jdbcConnectionList = PropertiesUtils.getJdbcConnectionMap(); |
70 | | - for(JdbcConnectionInfo jdbc : jdbcConnectionList) { |
71 | | - System.out.println("■ [ " + jdbc.getJdbcDBName() + " Monitoring Start ]\n"); |
72 | | - AbstractDatabase db = new JdbcDatabase(jdbc); |
73 | | - db.init(); |
74 | | - DBCheckRepository repo = new DBCheckRepositoryImpl(db); |
75 | | - DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, ReportFileRepo.getInstance()); |
76 | | - DBCheckBatch dbBatch = new DBCheckBatch(usecase); |
77 | | - dbBatch.startBatchArchiveUsageCheck(); |
78 | | - dbBatch.startBatchTableSpaceUsageCheck(); |
79 | | - dbBatch.startBatchASMDiskUsageCheck(); |
80 | | - //System.out.println("□ [ " + dbName + " Monitoring End ]\n\n"); |
81 | | - } |
82 | | - } |
83 | | - |
84 | | - public static void serverMonitoring() { |
85 | | - System.out.println("\n=================================================================================================================================="); |
86 | | - System.out.println(ConsoleUtils.BACKGROUND_CYAN + "※ Server Monitoring을 시작합니다." + ConsoleUtils.RESET); |
87 | | - System.out.println("==================================================================================================================================\n"); |
88 | | - |
89 | | - // Server Usage Check |
90 | | - List<JschConnectionInfo> jschConnectionList = PropertiesUtils.getJschConnectionMap(); |
91 | | - for(JschConnectionInfo jsch : jschConnectionList) { |
92 | | - System.out.println("■ [ " + jsch.getServerName() + " Monitoring Start ]\n"); |
93 | | - JschServer server = new JschServer(jsch); |
94 | | - server.init(); |
95 | | - ServerCheckRepository repo = new ServerCheckRepositoryImpl(server); |
96 | | - ServerCheckUsecase usecase = new ServerCheckUsecaseImpl(repo); |
97 | | - ServerCheckBatch serverBatch = new ServerCheckBatch(usecase); |
98 | | - |
99 | | - String alertLogFilePath = PropertiesUtils.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.filepath"); |
100 | | - String alertLogReadLine = PropertiesUtils.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.readline"); |
101 | | - String alertLogDateFormat = PropertiesUtils.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformat"); |
102 | | - String alertLogDateFormatRegex = PropertiesUtils.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformatregex"); |
103 | | - AlertLogCommand alc = new AlertLogCommand("tail", alertLogReadLine, alertLogFilePath, alertLogDateFormat, alertLogDateFormatRegex); |
104 | | - AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(alc, DateUtils.addDate(DateUtils.getToday("yyyy-MM-dd"), 0, 0, -1), DateUtils.getToday("yyyy-MM-dd")); |
105 | | - serverBatch.startBatchAlertLogCheckDuringPeriod(alcp); |
106 | | - serverBatch.startBatchOSDiskUsageCheck(); |
107 | | - //System.out.println("□ [ " + serverName + " Monitoring End ]\n\n"); |
108 | | - } |
109 | | - } |
110 | | -} |
111 | | - |
112 | | -/* |
113 | | -[추가해야 할 사항] |
114 | | - 1. 조회결과 엑셀파일 작성 |
115 | | - 2. 엑셀파일 읽어 모니터링 현황 가시화 |
116 | | - 3. AlertLog 내 Error 발생 키워드 수정 |
117 | | - 4. AlertLog Error 발생 시, 해당 부분의 로그 출력 |
118 | | - 5. 각 조회결과 사용량 기준치 초과 시 알람 전송 |
119 | | - 6. Console 출력내용 파일 형태로 저장 |
120 | | - 7. DB 조회결과 테이블형태로 출력 (j-text-utils 라이브러리 이용하여 구현. 더 나은 라이브러리 조사 필요) |
121 | | -*/ |
| 1 | +//package root.applications; |
| 2 | +// |
| 3 | +//import java.util.List; |
| 4 | +// |
| 5 | +//import root.common.database.contracts.AbstractDatabase; |
| 6 | +//import root.common.database.implement.JdbcDatabase; |
| 7 | +//import root.common.server.implement.JschServer; |
| 8 | +//import root.core.batch.DBCheckBatch; |
| 9 | +//import root.core.batch.ServerCheckBatch; |
| 10 | +//import root.core.domain.JdbcConnectionInfo; |
| 11 | +//import root.core.domain.JschConnectionInfo; |
| 12 | +//import root.core.repository.constracts.DBCheckRepository; |
| 13 | +//import root.core.repository.constracts.PropertyRepository; |
| 14 | +//import root.core.repository.constracts.ServerCheckRepository; |
| 15 | +//import root.core.repository.implement.DBCheckRepositoryImpl; |
| 16 | +//import root.core.repository.implement.PropertyRepositoryImpl; |
| 17 | +//import root.core.repository.implement.ReportFileRepo; |
| 18 | +//import root.core.repository.implement.ServerCheckRepositoryImpl; |
| 19 | +//import root.core.usecase.constracts.DBCheckUsecase; |
| 20 | +//import root.core.usecase.constracts.ServerCheckUsecase; |
| 21 | +//import root.core.usecase.implement.DBCheckUsecaseImpl; |
| 22 | +//import root.core.usecase.implement.ServerCheckUsecaseImpl; |
| 23 | +//import root.utils.ConsoleUtils; |
| 24 | +// |
| 25 | +//public class Application { |
| 26 | +// private static PropertyRepository propRepo = PropertyRepositoryImpl.getInstance(); |
| 27 | +// |
| 28 | +// public static void main(String[] args) { |
| 29 | +// |
| 30 | +// try { |
| 31 | +// String propertiesFilePath = ".\\config\\application.properties"; |
| 32 | +// |
| 33 | +// try { |
| 34 | +// propRepo.loadCombinedConfiguration(); |
| 35 | +// String lastUsePropertiesFile = propRepo.getCommonResource("filepath.config.lastuse"); |
| 36 | +// propRepo.loadConnectionInfoConfig(propertiesFilePath); |
| 37 | +// propRepo.loadCombinedConfiguration(); |
| 38 | +// }catch(Exception e) { |
| 39 | +// System.out.println("configuration loading error\n"+e+"\n"); |
| 40 | +// return; |
| 41 | +// } |
| 42 | +//// |
| 43 | +//// String dbMonitoring = propRepo.getMonitoringDBNames(); |
| 44 | +//// String serverMonitoring = propRepo.propConfig.getString("monitoring.server"); |
| 45 | +//// |
| 46 | +//// if("on".equals(dbMonitoring)) { |
| 47 | +//// dbMonitoring(); |
| 48 | +//// } |
| 49 | +//// |
| 50 | +//// if("on".equals(serverMonitoring)) { |
| 51 | +//// // serverMonitoring(); |
| 52 | +//// } |
| 53 | +// |
| 54 | +// } catch (Exception e) { |
| 55 | +// e.printStackTrace(); |
| 56 | +// } |
| 57 | +// |
| 58 | +// System.out.println("END"); |
| 59 | +// } |
| 60 | +// |
| 61 | +// public static void dbMonitoring() { |
| 62 | +// System.out.println("\n=================================================================================================================================="); |
| 63 | +// System.out.println(ConsoleUtils.BACKGROUND_CYAN + "※ DB Monitoring을 시작합니다." + ConsoleUtils.RESET); |
| 64 | +// System.out.println("==================================================================================================================================\n"); |
| 65 | +// |
| 66 | +// // DB Usage Check |
| 67 | +// List<JdbcConnectionInfo> jdbcConnectionList = propRepo.getJdbcConnectionMap(); |
| 68 | +// for(JdbcConnectionInfo jdbc : jdbcConnectionList) { |
| 69 | +// System.out.println("■ [ " + jdbc.getJdbcDBName() + " Monitoring Start ]\n"); |
| 70 | +// AbstractDatabase db = new JdbcDatabase(jdbc); |
| 71 | +// db.init(); |
| 72 | +// DBCheckRepository repo = new DBCheckRepositoryImpl(db); |
| 73 | +// DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, ReportFileRepo.getInstance()); |
| 74 | +// DBCheckBatch dbBatch = new DBCheckBatch(usecase); |
| 75 | +// dbBatch.startBatchArchiveUsageCheck(); |
| 76 | +// dbBatch.startBatchTableSpaceUsageCheck(); |
| 77 | +// dbBatch.startBatchASMDiskUsageCheck(); |
| 78 | +// //System.out.println("□ [ " + dbName + " Monitoring End ]\n\n"); |
| 79 | +// } |
| 80 | +// } |
| 81 | +// |
| 82 | +// public static void serverMonitoring() { |
| 83 | +// System.out.println("\n=================================================================================================================================="); |
| 84 | +// System.out.println(ConsoleUtils.BACKGROUND_CYAN + "※ Server Monitoring을 시작합니다." + ConsoleUtils.RESET); |
| 85 | +// System.out.println("==================================================================================================================================\n"); |
| 86 | +// |
| 87 | +// // Server Usage Check |
| 88 | +// List<JschConnectionInfo> jschConnectionList = propRepo.getJschConnectionMap(); |
| 89 | +// for(JschConnectionInfo jsch : jschConnectionList) { |
| 90 | +// System.out.println("■ [ " + jsch.getServerName() + " Monitoring Start ]\n"); |
| 91 | +// JschServer server = new JschServer(jsch); |
| 92 | +// server.init(); |
| 93 | +// ServerCheckRepository repo = new ServerCheckRepositoryImpl(server); |
| 94 | +// ServerCheckUsecase usecase = new ServerCheckUsecaseImpl(repo); |
| 95 | +// ServerCheckBatch serverBatch = new ServerCheckBatch(usecase); |
| 96 | +// |
| 97 | +//// String alertLogFilePath = propRepo..getString(jsch.getServerName().toLowerCase() + ".server.alertlog.filepath"); |
| 98 | +//// String alertLogReadLine = propRepo.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.readline"); |
| 99 | +//// String alertLogDateFormat = propRepo.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformat"); |
| 100 | +//// String alertLogDateFormatRegex = propRepo.propConfig.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformatregex"); |
| 101 | +//// AlertLogCommand alc = new AlertLogCommand("tail", alertLogReadLine, alertLogFilePath, alertLogDateFormat, alertLogDateFormatRegex); |
| 102 | +//// AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(alc, DateUtils.addDate(DateUtils.getToday("yyyy-MM-dd"), 0, 0, -1), DateUtils.getToday("yyyy-MM-dd")); |
| 103 | +//// serverBatch.startBatchAlertLogCheckDuringPeriod(alcp); |
| 104 | +//// serverBatch.startBatchOSDiskUsageCheck(); |
| 105 | +// //System.out.println("□ [ " + serverName + " Monitoring End ]\n\n"); |
| 106 | +// } |
| 107 | +// } |
| 108 | +//} |
| 109 | +// |
| 110 | +///* |
| 111 | +//[추가해야 할 사항] |
| 112 | +// 1. 조회결과 엑셀파일 작성 |
| 113 | +// 2. 엑셀파일 읽어 모니터링 현황 가시화 |
| 114 | +// 3. AlertLog 내 Error 발생 키워드 수정 |
| 115 | +// 4. AlertLog Error 발생 시, 해당 부분의 로그 출력 |
| 116 | +// 5. 각 조회결과 사용량 기준치 초과 시 알람 전송 |
| 117 | +// 6. Console 출력내용 파일 형태로 저장 |
| 118 | +// 7. DB 조회결과 테이블형태로 출력 (j-text-utils 라이브러리 이용하여 구현. 더 나은 라이브러리 조사 필요) |
| 119 | +//*/ |
0 commit comments