Update to latest upstream gopsutil

This commit is contained in:
Michael Schurter 2017-08-17 16:52:53 -07:00
parent e569763196
commit 6b8bac4929
6 changed files with 41 additions and 43 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}

30
vendor/vendor.json vendored
View File

@ -1154,44 +1154,44 @@
{
"checksumSHA1": "T2ThCk35wXAZGh37nrgA07199dA=",
"path": "github.com/shirou/gopsutil/cpu",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "T4uyVXPqCS5rj4vYLgv04as0Avw=",
"path": "github.com/shirou/gopsutil/disk",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "YBXpUckp1TtJf2mfMLx/bpnm22Q=",
"path": "github.com/shirou/gopsutil/host",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "np3IEfSkqCxxEnVBFB86AORndoI=",
"checksumSHA1": "jUWM0P4G1bHpO9CPS8gcr4rt1t0=",
"path": "github.com/shirou/gopsutil/internal/common",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "xIAuacHA0LNq1yM5Wd1q4lnbzxU=",
"path": "github.com/shirou/gopsutil/mem",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "moxD+mq0dMHnbTeFyeEHK0Iq7i8=",
"path": "github.com/shirou/gopsutil/net",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "C6ybAAUmWz+PQKqJ8byV7Nj5JXQ=",
"path": "github.com/shirou/gopsutil/process",
"revision": "565f5c8c5e5f8cf2f8a92cf9375f2f1c0e3ea034",
"revisionTime": "2017-08-16T21:54:50Z"
"revision": "1c211f0807a3436707409fa313599dd8c7a48664",
"revisionTime": "2017-08-17T03:45:37Z"
},
{
"checksumSHA1": "Nve7SpDmjsv6+rhkXAkfg/UQx94=",