Optimize hardware information

This commit is contained in:
2023-12-06 23:18:43 +08:00
parent c0e9380082
commit daee129b0b
2 changed files with 7 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import org.springframework.stereotype.Service
import oshi.SystemInfo import oshi.SystemInfo
import top.fatweb.api.properties.ServerProperties import top.fatweb.api.properties.ServerProperties
import top.fatweb.api.service.system.IStatisticsService import top.fatweb.api.service.system.IStatisticsService
import top.fatweb.api.util.ByteUtil
import top.fatweb.api.vo.system.HardwareInfoVo import top.fatweb.api.vo.system.HardwareInfoVo
import top.fatweb.api.vo.system.SoftwareInfoVo import top.fatweb.api.vo.system.SoftwareInfoVo
import java.time.LocalDateTime import java.time.LocalDateTime
@@ -39,6 +40,8 @@ class StatisticsServiceImpl : IStatisticsService {
cpuPhysicalPackageCount = systemInfo.hardware.processor.physicalPackageCount, cpuPhysicalPackageCount = systemInfo.hardware.processor.physicalPackageCount,
cpuPhysicalProcessorCount = systemInfo.hardware.processor.physicalProcessorCount, cpuPhysicalProcessorCount = systemInfo.hardware.processor.physicalProcessorCount,
cpuLogicalProcessorCount = systemInfo.hardware.processor.logicalProcessorCount, cpuLogicalProcessorCount = systemInfo.hardware.processor.logicalProcessorCount,
microarchitecture = systemInfo.hardware.processor.processorIdentifier.microarchitecture microarchitecture = systemInfo.hardware.processor.processorIdentifier.microarchitecture,
memories = "${ByteUtil.formatByteSize(systemInfo.hardware.memory.total)} (${systemInfo.hardware.memory.physicalMemory.joinToString(" + ") { ByteUtil.formatByteSize(it.capacity) }})",
disks = "${ByteUtil.formatByteSize(systemInfo.hardware.diskStores.sumOf { it.size })} (${systemInfo.hardware.diskStores.joinToString(" + ") {ByteUtil.formatByteSize(it.size)}})"
) )
} }

View File

@@ -7,5 +7,7 @@ data class HardwareInfoVo(
val cpuPhysicalPackageCount: Int, val cpuPhysicalPackageCount: Int,
val cpuPhysicalProcessorCount: Int, val cpuPhysicalProcessorCount: Int,
val cpuLogicalProcessorCount: Int, val cpuLogicalProcessorCount: Int,
val microarchitecture: String val microarchitecture: String,
val memories: String,
val disks: String
) )