Fix CPU counts error on Windows (#31)

This commit is contained in:
UUBulb
2024-06-25 22:10:32 +08:00
committed by GitHub
parent fb86c89de7
commit 532bca8867
5 changed files with 18 additions and 20 deletions
+7 -7
View File
@@ -88,15 +88,15 @@ func GetHost(agentConfig *model.AgentConfig) *model.Host {
if err != nil {
println("cpu.Info error:", err)
} else {
if runtime.GOOS == "linux" || runtime.GOOS == "windows" {
for i := 0; i < len(ci); i++ {
cpuModelCount[ci[i].ModelName]++
}
for model, count := range cpuModelCount {
for i := 0; i < len(ci); i++ {
cpuModelCount[ci[i].ModelName]++
}
for model, count := range cpuModelCount {
if len(ci) > 1 {
ret.CPU = append(ret.CPU, fmt.Sprintf("%s %d %s Core", model, count, cpuType))
} else {
ret.CPU = append(ret.CPU, fmt.Sprintf("%s %d %s Core", model, ci[0].Cores, cpuType))
}
} else {
ret.CPU = append(ret.CPU, fmt.Sprintf("%s %d %s Core", ci[0].ModelName, ci[0].Cores, cpuType))
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ func VersionCheck() bool {
}
re := regexp.MustCompile(`Build (\d+(\.\d+)?)`)
match := re.FindStringSubmatch(hi.PlatformVersion)
match := re.FindStringSubmatch(hi.KernelVersion)
if len(match) > 1 {
versionStr := match[1]