Skip to content

Commit 000a490

Browse files
authored
Merge pull request #156 from Dokyeongyun/develop
Develop
2 parents facac1a + f594b6c commit 000a490

File tree

70 files changed

+2894
-971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2894
-971
lines changed

config/common.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# DB Setting Contents
23
db.setting.contents=host,sid,user,password,port,driver,url
34
db.setting.oracle.driver.combo=thin
@@ -10,3 +11,10 @@ db.monitoring.contents=Archive Usage,TableSpace Usage,ASM Disk Usage
1011

1112
# Server monitoring Contents
1213
server.monitoring.contents=OS Disk Usage,Alert Log
14+
15+
unit.filesize=GB
16+
17+
unit.rounding=2
18+
19+
usage-ui-type = 2
20+

pom.xml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
33
<groupId>DBMonitoring</groupId>
44
<artifactId>DBMonitoring</artifactId>
55
<version>0.0.1-SNAPSHOT</version>
6+
<build>
7+
<plugins>
8+
<plugin>
9+
<groupId>org.apache.maven.plugins</groupId>
10+
<artifactId>maven-compiler-plugin</artifactId>
11+
<configuration>
12+
<source>9</source>
13+
<target>9</target>
14+
</configuration>
15+
</plugin>
16+
</plugins>
17+
</build>
618

7-
<dependencies>
19+
<dependencies>
820
<!-- https://mvnrepository.com/artifact/org.quartz-scheduler/quartz -->
921
<dependency>
1022
<groupId>org.quartz-scheduler</groupId>
@@ -68,13 +80,6 @@
6880
<version>30.1.1-jre</version>
6981
</dependency>
7082

71-
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
72-
<dependency>
73-
<groupId>com.opencsv</groupId>
74-
<artifactId>opencsv</artifactId>
75-
<version>5.4</version>
76-
</dependency>
77-
7883
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
7984
<dependency>
8085
<groupId>org.apache.poi</groupId>
@@ -173,5 +178,14 @@
173178
<artifactId>commons-lang3</artifactId>
174179
<version>3.11</version>
175180
</dependency>
181+
182+
<!-- Junit-jupiter-api -->
183+
<dependency>
184+
<groupId>org.junit.jupiter</groupId>
185+
<artifactId>junit-jupiter-api</artifactId>
186+
<version>5.7.0</version>
187+
<scope>test</scope>
188+
</dependency>
189+
176190
</dependencies>
177191
</project>

src/main/java/Test/Main.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import root.core.repository.constracts.DBCheckRepository;
1515
import root.core.repository.constracts.ServerCheckRepository;
1616
import root.core.repository.implement.DBCheckRepositoryImpl;
17-
import root.core.repository.implement.ReportRepositoryImpl;
17+
import root.core.repository.implement.ReportFileRepo;
1818
import root.core.repository.implement.ServerCheckRepositoryImpl;
1919
import root.core.usecase.constracts.DBCheckUsecase;
2020
import root.core.usecase.constracts.ServerCheckUsecase;
@@ -36,7 +36,7 @@ public static void main(String[] args) {
3636
PropertiesUtils.loadAppConfiguration(lastUsePropertiesFile, "connInfoConfig");
3737
PropertiesUtils.loadAppConfiguration(propertiesFilePath);
3838
PropertiesUtils.loadCombinedConfiguration();
39-
PropertiesUtils.loadAppConfiguration(".\\config\\connectioninfo\\connection.properties", "connInfoConfig");
39+
PropertiesUtils.loadAppConfiguration(".\\config\\connectioninfo\\test.properties", "connInfoConfig");
4040
}catch(Exception e) {
4141
System.out.println("configuration loading error\n"+e+"\n");
4242
return;
@@ -50,7 +50,7 @@ public static void main(String[] args) {
5050
}
5151

5252
if("on".equals(serverMonitoring)) {
53-
serverMonitoring();
53+
// serverMonitoring();
5454
}
5555

5656
} catch (Exception e) {
@@ -72,7 +72,7 @@ public static void dbMonitoring() {
7272
AbstractDatabase db = new JdbcDatabase(jdbc);
7373
db.init();
7474
DBCheckRepository repo = new DBCheckRepositoryImpl(db);
75-
DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, ReportRepositoryImpl.getInstance());
75+
DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, ReportFileRepo.getInstance());
7676
DBCheckBatch dbBatch = new DBCheckBatch(usecase);
7777
dbBatch.startBatchArchiveUsageCheck();
7878
dbBatch.startBatchTableSpaceUsageCheck();
@@ -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/applications/CsvReportSeparatorApp.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public static void main(String[] args) throws IOException {
5555

5656
for(String key : map.keySet()) {
5757
// System.out.println("[" + key + "]\n" + map.get(key));
58-
reportRepository.writeReportFile(filePath + "/" + fileName, key, ".txt", map.get(key).toString());
58+
// TODO 수정
59+
// reportRepository.writeReportFile(filePath + "/" + fileName, key, ".txt", map.get(key).toString());
5960
}
6061
}
6162
}

src/main/java/root/common/server/implement/JschServer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public void init() {
2525
session = null;
2626

2727
try {
28-
session = jsch.getSession(jschConnectionInfo.getUserName(), jschConnectionInfo.getHost(), jschConnectionInfo.getPort());
28+
session = jsch.getSession(jschConnectionInfo.getUserName(), jschConnectionInfo.getHost(),
29+
Integer.valueOf(jschConnectionInfo.getPort()));
2930
session.setPassword(jschConnectionInfo.getPassword());
3031

3132
Properties config = new Properties();

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
}
Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
11
package root.core.domain;
22

3-
import java.util.List;
3+
import java.util.Date;
44

5-
import com.opencsv.bean.CsvBindByName;
6-
import com.opencsv.bean.CsvCustomBindByName;
7-
8-
import lombok.AllArgsConstructor;
95
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
107
import lombok.NoArgsConstructor;
11-
import root.javafx.CustomView.UnitStringConverter;
8+
import root.utils.UnitUtils;
9+
import root.utils.UnitUtils.FileSize;
1210

13-
@AllArgsConstructor
1411
@NoArgsConstructor
12+
@EqualsAndHashCode(callSuper = false)
1513
@Data
16-
public class ASMDiskUsage {
14+
public class ASMDiskUsage extends MonitoringResult {
15+
16+
public ASMDiskUsage(Date monitoringDate, String asmDiskGroupName, String asmDiskGroupType, double totalRawSpace,
17+
double totalFreeSpace, double freeSpace, double usedSpace, double usedPercent, String resultMsg) {
18+
super(monitoringDate);
19+
this.asmDiskGroupName = asmDiskGroupName;
20+
this.asmDiskGroupType = asmDiskGroupType;
21+
this.totalRawSpace = totalRawSpace;
22+
this.totalFreeSpace = totalFreeSpace;
23+
this.freeSpace = freeSpace;
24+
this.usedSpace = usedSpace;
25+
this.usedPercent = usedPercent;
26+
this.resultMsg = resultMsg;
27+
}
28+
29+
public ASMDiskUsage(String monitoringDate, String monitoringTime, String asmDiskGroupName, String asmDiskGroupType,
30+
double totalRawSpace, double totalFreeSpace, double freeSpace, double usedSpace, double usedPercent,
31+
String resultMsg) {
32+
super(monitoringDate, monitoringTime);
33+
this.asmDiskGroupName = asmDiskGroupName;
34+
this.asmDiskGroupType = asmDiskGroupType;
35+
this.totalRawSpace = totalRawSpace;
36+
this.totalFreeSpace = totalFreeSpace;
37+
this.freeSpace = freeSpace;
38+
this.usedSpace = usedSpace;
39+
this.usedPercent = usedPercent;
40+
this.resultMsg = resultMsg;
41+
}
1742

18-
@CsvBindByName(column = "NAME")
1943
private String asmDiskGroupName;
2044

21-
@CsvBindByName(column = "TYPE")
2245
private String asmDiskGroupType;
2346

24-
@CsvCustomBindByName(column = "TOTAL_RAW(MB)", converter = UnitStringConverter.class)
25-
private UnitString totalRawSpace;
47+
private double totalRawSpace;
2648

27-
@CsvCustomBindByName(column = "TOTAL_USABLE(MB)", converter = UnitStringConverter.class)
28-
private UnitString totalFreeSpace;
49+
private double totalFreeSpace;
2950

30-
@CsvCustomBindByName(column = "FREE(MB)", converter = UnitStringConverter.class)
31-
private UnitString freeSpace;
51+
private double freeSpace;
3252

33-
@CsvCustomBindByName(column = "USED(MB)", converter = UnitStringConverter.class)
34-
private UnitString usedSpace;
53+
private double usedSpace;
3554

36-
@CsvCustomBindByName(column = "USED(%)", converter = UnitStringConverter.class)
37-
private UnitString usedPercent;
55+
private double usedPercent;
3856

39-
@CsvBindByName(column = "RESULT")
4057
private String resultMsg;
4158

42-
public static String toCsvString(List<ASMDiskUsage> list) {
43-
StringBuffer toCsv = new StringBuffer();
44-
toCsv.append("NAME,TYPE,TOTAL_RAW(MB),TOTAL_USABLE(MB),USED(MB),USED(%),FREE(MB),RESULT").append("\n");
45-
46-
for (ASMDiskUsage data : list) {
47-
toCsv.append(data.getAsmDiskGroupName()).append(",");
48-
toCsv.append(data.getAsmDiskGroupType()).append(",");
49-
toCsv.append(data.getTotalRawSpace().getValue()).append(data.getTotalRawSpace().getUnit()).append(",");
50-
toCsv.append(data.getTotalFreeSpace().getValue()).append(data.getTotalFreeSpace().getUnit()).append(",");
51-
toCsv.append(data.getFreeSpace().getValue()).append(data.getFreeSpace().getUnit()).append(",");
52-
toCsv.append(data.getUsedSpace().getValue()).append(data.getUsedSpace().getUnit()).append(",");
53-
toCsv.append(data.getUsedPercent().getValue()).append(data.getUsedPercent().getUnit()).append(",");
54-
toCsv.append(data.getResultMsg()).append("\n");
55-
}
56-
57-
return toCsv.toString();
59+
@Override
60+
public void convertUnit(FileSize fromUnit, FileSize toUnit, int round) {
61+
this.totalRawSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, totalRawSpace, round);
62+
this.totalFreeSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, totalFreeSpace, round);
63+
this.freeSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, freeSpace, round);
64+
this.usedSpace = UnitUtils.convertFileUnit(fromUnit, toUnit, usedSpace, round);
5865
}
66+
5967
}

0 commit comments

Comments
 (0)