shirou_gopsutil/common/common_darwin.go

21 lines
379 B
Go
Raw Normal View History

// +build darwin
2014-12-30 21:09:05 +08:00
package common
import (
"os/exec"
"strings"
)
func DoSysctrl(mib string) ([]string, error) {
out, err := exec.Command("/usr/sbin/sysctl", "-n", mib).Output()
if err != nil {
return []string{}, err
}
v := strings.Replace(string(out), "{ ", "", 1)
v = strings.Replace(string(v), " }", "", 1)
values := strings.Fields(string(v))
return values, nil
}