mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Update to latest upstream gopsutil
This commit is contained in:
16
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
16
vendor/github.com/shirou/gopsutil/internal/common/common.go
generated
vendored
@@ -358,3 +358,19 @@ func Pipeline(cmds ...*exec.Cmd) ([]byte, []byte, error) {
|
||||
// Return the pipeline output and the collected standard error
|
||||
return output.Bytes(), stderr.Bytes(), nil
|
||||
}
|
||||
|
||||
// getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running
|
||||
// sysctl commands (see DoSysctrl).
|
||||
func getSysctrlEnv(env []string) []string {
|
||||
foundLC := false
|
||||
for i, line := range env {
|
||||
if strings.HasPrefix(line, "LC_ALL") {
|
||||
env[i] = "LC_ALL=C"
|
||||
foundLC = true
|
||||
}
|
||||
}
|
||||
if !foundLC {
|
||||
env = append(env, "LC_ALL=C")
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
9
vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
generated
vendored
@@ -12,16 +12,13 @@ import (
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
err := os.Setenv("LC_ALL", "C")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
sysctl, err := exec.LookPath("/usr/sbin/sysctl")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
out, err := exec.Command(sysctl, "-n", mib).Output()
|
||||
cmd := exec.Command(sysctl, "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
8
vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
generated
vendored
8
vendor/github.com/shirou/gopsutil/internal/common/common_freebsd.go
generated
vendored
@@ -12,15 +12,13 @@ import (
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
err := os.Setenv("LC_ALL", "C")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
sysctl, err := exec.LookPath("/sbin/sysctl")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
out, err := exec.Command(sysctl, "-n", mib).Output()
|
||||
cmd := exec.Command(sysctl, "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
13
vendor/github.com/shirou/gopsutil/internal/common/common_linux.go
generated
vendored
13
vendor/github.com/shirou/gopsutil/internal/common/common_linux.go
generated
vendored
@@ -9,23 +9,12 @@ import (
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
hostEnv := os.Environ()
|
||||
foundLC := false
|
||||
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")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
cmd := exec.Command(sysctl, "-n", mib)
|
||||
cmd.Env = hostEnv
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
|
||||
8
vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
generated
vendored
8
vendor/github.com/shirou/gopsutil/internal/common/common_openbsd.go
generated
vendored
@@ -12,15 +12,13 @@ import (
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
err := os.Setenv("LC_ALL", "C")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
sysctl, err := exec.LookPath("/sbin/sysctl")
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
out, err := exec.Command(sysctl, "-n", mib).Output()
|
||||
cmd := exec.Command(sysctl, "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user