parent
3aa2ffab12
commit
565f5c8c5e
|
@ -9,15 +9,24 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func DoSysctrl(mib string) ([]string, error) {
|
func DoSysctrl(mib string) ([]string, error) {
|
||||||
err := os.Setenv("LC_ALL", "C")
|
hostEnv := os.Environ()
|
||||||
if err != nil {
|
foundLC := false
|
||||||
return []string{}, err
|
for i, line := range hostEnv {
|
||||||
|
if strings.HasPrefix(line, "LC_ALL") {
|
||||||
|
hostEnv[i] = "LC_ALL=C"
|
||||||
|
foundLC = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !foundLC {
|
||||||
|
hostEnv = append(hostEnv, "LC_ALL=C")
|
||||||
}
|
}
|
||||||
sysctl, err := exec.LookPath("/sbin/sysctl")
|
sysctl, err := exec.LookPath("/sbin/sysctl")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, err
|
return []string{}, err
|
||||||
}
|
}
|
||||||
out, err := exec.Command(sysctl, "-n", mib).Output()
|
cmd := exec.Command(sysctl, "-n", mib)
|
||||||
|
cmd.Env = hostEnv
|
||||||
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, err
|
return []string{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue