Skip to content

Commit

Permalink
update monitor.go
Browse files Browse the repository at this point in the history
  • Loading branch information
xOS authored Jan 5, 2024
1 parent 38c1605 commit 0d7cfe7
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cmd/agent/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,15 @@ 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)
} 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))
}
}
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))
}

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

0 comments on commit 0d7cfe7

Please sign in to comment.