update status api

This commit is contained in:
Timi
2026-04-13 00:09:48 +08:00
parent 78163441dd
commit dc20070bf8
8 changed files with 21 additions and 29 deletions

View File

@@ -348,10 +348,10 @@ public class ServerStatus implements TimiJava {
private String mountPoint;
/** 分区总空间 */
private long totalBytes;
private long total;
/** 分区已用空间 */
private Long usedBytes;
private Long used;
/** 磁盘传输耗时 */
private long transferTimeMs;

View File

@@ -26,17 +26,17 @@ public class DockerController {
private final DockerService dockerService;
@GetMapping("/containers")
@GetMapping("/container")
public List<DockerContainerSummaryView> listContainers() {
return dockerService.listContainers();
}
@GetMapping("/containers/{containerId}/status")
@GetMapping("/container/{containerId}/status")
public DockerContainerStatusView getContainerStatus(@PathVariable String containerId) {
return dockerService.getContainerStatus(containerId);
}
@GetMapping("/containers/{containerId}/history")
@GetMapping("/container/{containerId}/history")
public DockerContainerHistoryView getContainerHistory(@PathVariable String containerId, @RequestParam(required = false) String window) {
return dockerService.getContainerHistory(containerId, window);
}

View File

@@ -72,7 +72,6 @@ public class StatusServiceImplement implements StatusService {
SystemStatusDataView.OS os = new SystemStatusDataView.OS();
os.setName(serverStatus.getOs().getName());
os.setBootAt(serverStatus.getOs().getBootAt());
os.setUptimeMs(Math.max(0, serverTime - serverStatus.getOs().getBootAt()));
snapshot.setOs(os);
}
if (selectedMetrics.contains(Metric.CPU)) {
@@ -80,8 +79,8 @@ public class StatusServiceImplement implements StatusService {
cpu.setModel(serverStatus.getCpu().getName());
cpu.setPhysicalCores(serverStatus.getCpu().getCoreCount());
cpu.setLogicalCores(serverStatus.getCpu().getLogicalCount());
cpu.setUsagePercent(lastDouble(serverStatus.getCpu().getUsed()));
cpu.setSystemPercent(lastDouble(serverStatus.getCpu().getSystem()));
cpu.setUsageTotal(lastDouble(serverStatus.getCpu().getUsed()));
cpu.setUsageSystem(lastDouble(serverStatus.getCpu().getSystem()));
cpu.setTemperatureCelsius(serverStatus.getCpu().getTemperature());
snapshot.setCpu(cpu);
}
@@ -91,7 +90,6 @@ public class StatusServiceImplement implements StatusService {
Long swapUsedBytes = lastLong(serverStatus.getMemory().getSwapUsed());
memory.setTotalBytes(serverStatus.getMemory().getSize());
memory.setUsedBytes(usedBytes);
memory.setUsagePercent(toPercent(usedBytes, serverStatus.getMemory().getSize()));
memory.setSwapTotalBytes(serverStatus.getMemory().getSwapSize());
memory.setSwapUsedBytes(swapUsedBytes);
snapshot.setMemory(memory);
@@ -160,9 +158,9 @@ public class StatusServiceImplement implements StatusService {
item.setPartitionType(partition.getPartitionType());
item.setUuid(partition.getUuid());
item.setMountPoint(partition.getMountPoint());
item.setTotalBytes(partition.getTotalBytes());
item.setUsedBytes(partition.getUsedBytes());
item.setUsagePercent(toPercent(partition.getUsedBytes(), partition.getTotalBytes()));
item.setTotal(partition.getTotal());
item.setUsed(partition.getUsed());
item.setUsagePercent(toPercent(partition.getUsed(), partition.getTotal()));
item.setTransferTimeMs(partition.getTransferTimeMs());
storagePartitions.add(item);
}

View File

@@ -23,7 +23,7 @@ public class UpsServiceImplement implements UpsService {
private final UpsStatusTask upsStatusTask;
private final UpsStatusStore upsStatusStore;
@Value("${ups.collect-rate-ms:60000}")
@Value("${ups.collect-rate-ms:3000}")
private long collectRateMs;
@Override

View File

@@ -28,7 +28,7 @@ public class UpsStatusTask implements SchedulingConfigurer {
private final UpsStatusClient upsStatusClient;
private final UpsStatusStore upsStatusStore;
@Value("${ups.collect-enabled:false}")
@Value("${ups.collect-enabled:true}")
private boolean collectEnabled;
@Value("${ups.collect-rate-ms:60000}")

View File

@@ -38,10 +38,10 @@ public class CpuStatusCollector extends AbstractDequeStatusCollector {
long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - lastCpuTicks[CentralProcessor.TickType.IRQ.getIndex()];
long softIrq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - lastCpuTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - lastCpuTicks[CentralProcessor.TickType.STEAL.getIndex()];
long total = user + nice + sys + idle + ioWait + irq + softIrq + steal;
double total = user + nice + sys + idle + ioWait + irq + softIrq + steal;
if (0 < total) {
putDeque(context, context.getStatus().getCpu().getSystem(), 100D * sys / total);
putDeque(context, context.getStatus().getCpu().getUsed(), 100 - 100D * idle / total);
putDeque(context, context.getStatus().getCpu().getSystem(), sys / total);
putDeque(context, context.getStatus().getCpu().getUsed(), 1 - idle / total);
}
}
lastCpuTicks = ticks;

View File

@@ -38,13 +38,13 @@ public class StorageStatusCollector implements StatusCollector {
item.setPartitionType(partition.getType());
item.setUuid(partition.getUuid());
item.setMountPoint(partition.getMountPoint());
item.setTotalBytes(partition.getSize());
item.setTotal(partition.getSize());
item.setTransferTimeMs(diskStore.getTransferTime());
OSFileStore fileStore = matchFileStore(partition, fileStoreMap);
if (fileStore != null) {
fileStore.updateAttributes();
item.setUsedBytes(fileStore.getTotalSpace() - fileStore.getUsableSpace());
item.setUsed(fileStore.getTotalSpace() - fileStore.getUsableSpace());
}
context.getStatus().getStoragePartitions().add(item);
}

View File

@@ -101,9 +101,6 @@ public class SystemStatusDataView {
/** 启动时间 */
private long bootAt;
/** 运行时长 */
private long uptimeMs;
}
/**
@@ -125,10 +122,10 @@ public class SystemStatusDataView {
private int logicalCores;
/** 总占用 */
private Double usagePercent;
private Double usageTotal;
/** 系统占用 */
private Double systemPercent;
private Double usageSystem;
/** 温度 */
private double temperatureCelsius;
@@ -149,9 +146,6 @@ public class SystemStatusDataView {
/** 已用内存 */
private Long usedBytes;
/** 使用率 */
private Double usagePercent;
/** 交换分区总量 */
private long swapTotalBytes;
@@ -364,10 +358,10 @@ public class SystemStatusDataView {
private String mountPoint;
/** 分区总空间 */
private long totalBytes;
private long total;
/** 已用空间 */
private Long usedBytes;
private Long used;
/** 使用率 */
private Double usagePercent;