mirror of
https://github.com/oneclickvirt/basics.git
synced 2025-10-10 02:50:21 +08:00
update
This commit is contained in:
@@ -173,8 +173,7 @@ func getCpuInfo(ret *model.SystemInfo, cpuType string) (*model.SystemInfo, error
|
|||||||
}
|
}
|
||||||
// 使用 sysctl 获取信息 - 特化适配 freebsd openbsd 系统
|
// 使用 sysctl 获取信息 - 特化适配 freebsd openbsd 系统
|
||||||
path, exit := utils.GetPATH("sysctl")
|
path, exit := utils.GetPATH("sysctl")
|
||||||
fmt.Println("sysctl path:", path, exit)
|
if exit {
|
||||||
if exit && checkSysctlVersion(path) {
|
|
||||||
if ret.CpuModel == "" || len(ret.CpuModel) < 3 {
|
if ret.CpuModel == "" || len(ret.CpuModel) < 3 {
|
||||||
cname, err := getSysctlValue(path, "hw.model")
|
cname, err := getSysctlValue(path, "hw.model")
|
||||||
fmt.Println(cname)
|
fmt.Println(cname)
|
||||||
|
@@ -5,16 +5,16 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkSysctlVersion(path string) bool {
|
// func checkSysctlVersion(path string) bool {
|
||||||
out, err := exec.Command(path, "-h").Output()
|
// out, err := exec.Command(path, "-h").Output()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
if strings.Contains(string(out), "error") {
|
// if strings.Contains(string(out), "error") {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
|
||||||
func getSysctlValue(path, key string) (string, error) {
|
func getSysctlValue(path, key string) (string, error) {
|
||||||
out, err := exec.Command(path, "-n", key).Output()
|
out, err := exec.Command(path, "-n", key).Output()
|
||||||
|
Reference in New Issue
Block a user