From 180586d8aa43e63e86c4acdaf800c2360089ff30 Mon Sep 17 00:00:00 2001 From: Akizon77 Date: Tue, 6 May 2025 21:08:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#3=20=E4=BF=AE=E6=94=B9CPU=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E8=AF=86=E5=88=AB=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitoring/cpu.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 {