Skip to content

Commit

Permalink
Revert "修复cpu核心数识别错误 (#7)"
Browse files Browse the repository at this point in the history
This reverts commit 9abb5c0.
  • Loading branch information
naiba committed Jan 10, 2024
1 parent 9abb5c0 commit af85ddd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Agent of Nezha Monitoring
<!--GAMFC_DELIMITER--><a href="https://github.com/naiba" title="naiba">
<img src="https://avatars.githubusercontent.com/u/29243953?v=4" width="50;" alt="naiba"/>
</a>
<a href="https://github.com/wwng2333" title="Crazy">
<img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/>
</a>
<a href="https://github.com/zhangnew" title="zhangnew">
<img src="https://avatars.githubusercontent.com/u/9146834?v=4" width="50;" alt="zhangnew"/>
</a>
<a href="https://github.com/wwng2333" title="Crazy">
<img src="https://avatars.githubusercontent.com/u/17147265?v=4" width="50;" alt="Crazy"/>
</a>
<a href="https://github.com/Erope" title="卖女孩的小火柴">
<img src="https://avatars.githubusercontent.com/u/44471469?v=4" width="50;" alt="卖女孩的小火柴"/>
</a><!--GAMFC_DELIMITER_END-->
14 changes: 8 additions & 6 deletions pkg/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 af85ddd

Please sign in to comment.