Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
xOS committed Jan 18, 2024
1 parent 0d7cfe7 commit 839b19c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/agent/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ func GetHost(agentConfig *model.AgentConfig) *model.Host {
ret.BootTime = hi.BootTime
}

cpuModelCount := make(map[string]int)
ci, err := cpu.Info()
if err != nil {
println("cpu.Info error:", err)
}
count, err := cpu.Counts(false)
if err != nil {
println("cpu.Counts error:", err)
} else if len(ci) > 0 {
ret.CPU = append(ret.CPU, fmt.Sprintf("%s %d %s Core", ci[0].ModelName, count, cpuType))
} else {
for i := 0; i < len(ci); i++ {
cpuModelCount[ci[i].ModelName]++
}
for model, count := range cpuModelCount {
ret.CPU = append(ret.CPU, fmt.Sprintf("%s %d %s Core", model, count, cpuType))
}
}

ret.DiskTotal, _ = getDiskTotalAndUsed(agentConfig)
Expand Down

0 comments on commit 839b19c

Please sign in to comment.