Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
spiritLHLS committed Jul 26, 2024
1 parent a762937 commit 85c38f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions system/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ func getCpuInfo(ret *model.SystemInfo, cpuType string) (*model.SystemInfo, error
}
// 使用 sysctl 获取信息 - 特化适配 freebsd openbsd 系统
path, exit := utils.GetPATH("sysctl")
fmt.Println("sysctl path:", path, exit)
if exit && checkSysctlVersion(path) {
if exit {
if ret.CpuModel == "" || len(ret.CpuModel) < 3 {
cname, err := getSysctlValue(path, "hw.model")
fmt.Println(cname)
Expand Down
20 changes: 10 additions & 10 deletions system/sysctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import (
"strings"
)

func checkSysctlVersion(path string) bool {
out, err := exec.Command(path, "-h").Output()
if err != nil {
return false
}
if strings.Contains(string(out), "error") {
return false
}
return true
}
// func checkSysctlVersion(path string) bool {
// out, err := exec.Command(path, "-h").Output()
// if err != nil {
// return false
// }
// if strings.Contains(string(out), "error") {
// return false
// }
// return true
// }

func getSysctlValue(path, key string) (string, error) {
out, err := exec.Command(path, "-n", key).Output()
Expand Down

0 comments on commit 85c38f0

Please sign in to comment.