|
|
@@ -9,8 +9,6 @@ import java.lang.management.ManagementFactory;
|
|
|
import java.lang.management.MemoryMXBean;
|
|
|
import java.time.Instant;
|
|
|
import java.time.ZoneId;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@Getter
|
|
|
public class SystemHealth {
|
|
|
@@ -41,11 +39,17 @@ public class SystemHealth {
|
|
|
private long diskFree;
|
|
|
private double diskUsage;
|
|
|
|
|
|
- private final Map<String, GcStats> gcStatsMap = new HashMap<>();
|
|
|
+// private final Map<String, GcStats> gcStatsMap = new HashMap<>();
|
|
|
private String gcName;
|
|
|
- private long gcCount = 0;
|
|
|
- private long gcTime = 0;
|
|
|
- private String jvmStartTime;
|
|
|
+ private long gcTotalCount = 0;
|
|
|
+ private long gcTotalTime = 0;
|
|
|
+ private long gcTotalAvgTime = 0;
|
|
|
+
|
|
|
+ private long gcRecentCount = 0;
|
|
|
+ private long gcRecentTime = 0;
|
|
|
+ private long gcRecentAvgTime = 0;
|
|
|
+
|
|
|
+ private final String jvmStartTime;
|
|
|
|
|
|
public SystemHealth() {
|
|
|
this.jvmStartTime = Instant.ofEpochMilli(
|
|
|
@@ -109,13 +113,26 @@ public class SystemHealth {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ long totalGcCount = 0;
|
|
|
+ long totalGcTime = 0;
|
|
|
for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
|
|
|
- this.gcName = gc.getName();
|
|
|
- this.gcCount += gc.getCollectionCount();
|
|
|
- this.gcTime += gc.getCollectionTime();
|
|
|
- gcStatsMap.put(gc.getName(), new GcStats(gc.getCollectionCount(), gc.getCollectionTime()));
|
|
|
+ totalGcCount += gc.getCollectionCount();
|
|
|
+ totalGcTime += gc.getCollectionTime();
|
|
|
+// this.gcName = gc.getName();
|
|
|
+// gcStatsMap.put(gc.getName(), new GcStats(gc.getCollectionCount(), gc.getCollectionTime()));
|
|
|
}
|
|
|
|
|
|
+ // 누적 평균
|
|
|
+ this.gcTotalAvgTime = totalGcTime > 0 ? Math.round((double) totalGcTime / totalGcCount) : 0;
|
|
|
+
|
|
|
+ // 최근 변화량
|
|
|
+ this.gcRecentCount = totalGcCount - this.gcTotalCount;
|
|
|
+ this.gcRecentTime = totalGcTime - this.gcTotalTime;
|
|
|
+ this.gcRecentAvgTime = gcTotalCount > 0 ? Math.round((double) this.gcRecentTime / gcTotalCount) : 0;
|
|
|
+
|
|
|
+ this.gcTotalCount = totalGcCount;
|
|
|
+ this.gcTotalTime = totalGcTime;
|
|
|
+
|
|
|
// for (File root : File.listRoots()) {
|
|
|
// if (root.exists() && root.canRead()) {
|
|
|
// long total = root.getTotalSpace();
|