Skip to content

Commit 9254f22

Browse files
committed
Change OS Disk monitoring command that return result in KiloByte
1 parent e13c177 commit 9254f22

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

src/main/java/root/applications/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static void serverMonitoring() {
103103
AlertLogCommand alc = new AlertLogCommand("tail", alertLogReadLine, alertLogFilePath, alertLogDateFormat, alertLogDateFormatRegex);
104104
AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(alc, DateUtils.addDate(DateUtils.getToday("yyyy-MM-dd"), 0, 0, -1), DateUtils.getToday("yyyy-MM-dd"));
105105
serverBatch.startBatchAlertLogCheckDuringPeriod(alcp);
106-
serverBatch.startBatchOSDiskUsageCheck("df -Ph");
106+
serverBatch.startBatchOSDiskUsageCheck();
107107
//System.out.println("□ [ " + serverName + " Monitoring End ]\n\n");
108108
}
109109
}

src/main/java/root/core/batch/ServerCheckBatch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public void startBatchAlertLogCheckDuringPeriod(AlertLogCommandPeriod alcp) {
2727
}
2828
}
2929

30-
public void startBatchOSDiskUsageCheck(String command) {
30+
public void startBatchOSDiskUsageCheck() {
3131
try {
32-
this.serverCheckUsecase.printOSDiskUsage(command);
33-
this.serverCheckUsecase.writeExcelOSDiskUsage(command);
34-
this.serverCheckUsecase.writeCsvOSDiskUsage(command);
32+
this.serverCheckUsecase.printOSDiskUsage();
33+
this.serverCheckUsecase.writeExcelOSDiskUsage();
34+
this.serverCheckUsecase.writeCsvOSDiskUsage();
3535
}catch(Exception e) {
3636
e.printStackTrace();
3737
}

src/main/java/root/core/repository/constracts/ServerCheckRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ public interface ServerCheckRepository {
1919
int getAlertLogFileLineCount(AlertLogCommand alc);
2020
String checkAlertLog(AlertLogCommand alc);
2121
AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alc);
22-
List<OSDiskUsage> checkOSDiskUsage(String command);
22+
List<OSDiskUsage> checkOSDiskUsage();
2323
}

src/main/java/root/core/repository/implement/ServerCheckRepositoryImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ public AlertLog checkAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
209209
}
210210

211211
@Override
212-
public List<OSDiskUsage> checkOSDiskUsage(String command) {
212+
public List<OSDiskUsage> checkOSDiskUsage() {
213213
List<OSDiskUsage> list = new ArrayList<>();
214214
try {
215215
Session session = this.getSession();
216216
session = this.connectSession(session);
217-
Channel channel = jsch.openExecChannel(session, command);
217+
Channel channel = jsch.openExecChannel(session, "df --block-size=K -P");
218218
InputStream in = jsch.connectChannel(channel);
219219
String result = IOUtils.toString(in, "UTF-8");
220220
list = stringToOsDiskUsageList(result);

src/main/java/root/core/usecase/constracts/ServerCheckUsecase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
public interface ServerCheckUsecase {
1111
void printAlertLog(AlertLogCommand alc);
1212
void printAlertLogDuringPeriod(AlertLogCommandPeriod alcp);
13-
void printOSDiskUsage(String command);
13+
void printOSDiskUsage();
1414

15-
void writeExcelOSDiskUsage(String command) throws Exception;
16-
void writeCsvOSDiskUsage(String command) throws Exception;
15+
void writeExcelOSDiskUsage() throws Exception;
16+
void writeCsvOSDiskUsage() throws Exception;
1717

18-
List<OSDiskUsage> getCurrentOSDiskUsage(String command);
18+
List<OSDiskUsage> getCurrentOSDiskUsage();
1919
AlertLog getAlertLogDuringPeriod(AlertLogCommandPeriod alcp);
2020
}

src/main/java/root/core/usecase/implement/ServerCheckUsecaseImpl.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ public void printAlertLogDuringPeriod(AlertLogCommandPeriod alcp) {
160160
}
161161

162162
@Override
163-
public void printOSDiskUsage(String command) {
164-
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage(command);
163+
public void printOSDiskUsage() {
164+
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage();
165165

166166
boolean isError = false;
167167
for(OSDiskUsage data : result) {
@@ -187,10 +187,10 @@ public void printOSDiskUsage(String command) {
187187
}
188188

189189
@Override
190-
public void writeExcelOSDiskUsage(String command) throws Exception {
190+
public void writeExcelOSDiskUsage() throws Exception {
191191
if(!"STS".equals(serverCheckRepository.getServerName())) return;
192192

193-
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage(command);
193+
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage();
194194

195195
int year = Integer.parseInt(DateUtils.getToday("yyyy"));
196196
int month = Integer.parseInt(DateUtils.getToday("MM"));
@@ -232,10 +232,10 @@ public void writeExcelOSDiskUsage(String command) throws Exception {
232232
}
233233

234234
@Override
235-
public void writeCsvOSDiskUsage(String command) throws Exception {
235+
public void writeCsvOSDiskUsage() throws Exception {
236236
String serverName = serverCheckRepository.getServerName();
237237

238-
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage(command);
238+
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage();
239239

240240
String filePath = "C:\\Users\\aserv\\Documents\\WorkSpace_DBMonitoring_Quartz\\DBMonitoring\\report\\OSDiskUsage\\";
241241
String fileName = serverName;
@@ -256,8 +256,8 @@ public void writeCsvOSDiskUsage(String command) throws Exception {
256256
}
257257

258258
@Override
259-
public List<OSDiskUsage> getCurrentOSDiskUsage(String command) {
260-
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage(command);
259+
public List<OSDiskUsage> getCurrentOSDiskUsage() {
260+
List<OSDiskUsage> result = serverCheckRepository.checkOSDiskUsage();
261261
return result;
262262
}
263263

src/main/java/root/javafx/Controller/RunMenuController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public void runMonitoring(ActionEvent e) {
310310
AlertLogCommand alc = new AlertLogCommand("tail", alertLogReadLine, alertLogFilePath, alertLogDateFormat, alertLogDateFormatRegex);
311311
AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(alc, alertLogStartDay, alertLogEndDay);
312312

313-
osDiskUsageMAP.addTableDataSet(server.getServerName(), usecase.getCurrentOSDiskUsage("df -Ph"));
313+
osDiskUsageMAP.addTableDataSet(server.getServerName(), usecase.getCurrentOSDiskUsage());
314314
alertLogMonitoringResultMap.put(server.getServerName(), usecase.getAlertLogDuringPeriod(alcp));
315315
}
316316

0 commit comments

Comments
 (0)