From 85c38f05eac128fcaf34d1f71407a76ad1f74bf2 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:07:51 +0000 Subject: [PATCH] update --- system/cpu.go | 3 +-- system/sysctl.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/system/cpu.go b/system/cpu.go index 82c4c40..7626ba7 100644 --- a/system/cpu.go +++ b/system/cpu.go @@ -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) diff --git a/system/sysctl.go b/system/sysctl.go index 43bf6be..153fe6f 100644 --- a/system/sysctl.go +++ b/system/sysctl.go @@ -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()