diff --git a/monitoring/cpu.go b/monitoring/cpu.go index 3e85f86..29ea7e3 100644 --- a/monitoring/cpu.go +++ b/monitoring/cpu.go @@ -2,6 +2,7 @@ package monitoring import ( "runtime" + "strconv" "strings" "time" @@ -24,8 +25,16 @@ func Cpu() CpuInfo { // multiple CPU // 多个 CPU if len(info) > 1 { + cpuCountMap := make(map[string]int) for _, cpu := range info { - cpuinfo.CPUName += cpu.ModelName + ", " + cpuCountMap[cpu.ModelName]++ + } + for modelName, count := range cpuCountMap { + if count > 1 { + cpuinfo.CPUName += modelName + " x " + strconv.Itoa(count) + ", " + } else { + cpuinfo.CPUName += modelName + ", " + } } cpuinfo.CPUName = cpuinfo.CPUName[:len(cpuinfo.CPUName)-2] // Remove trailing comma and space } else if len(info) == 1 {