summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/shirou/gopsutil
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/shirou/gopsutil')
-rw-r--r--vendor/github.com/shirou/gopsutil/cpu/cpu.go3
-rw-r--r--vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk_darwin.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go59
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/disk/disk_linux.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_darwin.go10
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_fallback.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_freebsd.go19
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_linux.go43
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go43
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_openbsd.go4
-rw-r--r--vendor/github.com/shirou/gopsutil/host/host_solaris.go25
-rw-r--r--vendor/github.com/shirou/gopsutil/internal/common/common.go12
-rw-r--r--vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go5
-rw-r--r--vendor/github.com/shirou/gopsutil/internal/common/common_unix.go9
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem.go9
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_darwin.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go75
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_linux.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_openbsd.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_solaris.go9
-rw-r--r--vendor/github.com/shirou/gopsutil/mem/mem_windows.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/net/net.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/net/net_darwin.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/net/net_freebsd.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/net/net_openbsd.go6
-rw-r--r--vendor/github.com/shirou/gopsutil/net/net_unix.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/process/process.go10
-rw-r--r--vendor/github.com/shirou/gopsutil/process/process_darwin.go32
-rw-r--r--vendor/github.com/shirou/gopsutil/process/process_freebsd.go2
-rw-r--r--vendor/github.com/shirou/gopsutil/process/process_linux.go8
-rw-r--r--vendor/github.com/shirou/gopsutil/process/process_openbsd.go4
38 files changed, 303 insertions, 158 deletions
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu.go b/vendor/github.com/shirou/gopsutil/cpu/cpu.go
index 049869e..ceaf77f 100644
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu.go
+++ b/vendor/github.com/shirou/gopsutil/cpu/cpu.go
@@ -54,10 +54,9 @@ type lastPercent struct {
}
var lastCPUPercent lastPercent
-var invoke common.Invoker
+var invoke common.Invoker = common.Invoke{}
func init() {
- invoke = common.Invoke{}
lastCPUPercent.Lock()
lastCPUPercent.lastCPUTimes, _ = Times(false)
lastCPUPercent.lastPerCPUTimes, _ = Times(true)
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go
index 001517e..74d2737 100644
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/cpu/cpu_darwin.go
@@ -45,7 +45,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
if err != nil {
return ret, err
}
- out, err := invoke.Command(sysctl, "machdep.cpu")
+ out, err := invoke.CommandWithContext(ctx, sysctl, "machdep.cpu")
if err != nil {
return ret, err
}
@@ -99,7 +99,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
// Use the rated frequency of the CPU. This is a static value and does not
// account for low power or Turbo Boost modes.
- out, err = invoke.Command(sysctl, "hw.cpufrequency")
+ out, err = invoke.CommandWithContext(ctx, sysctl, "hw.cpufrequency")
if err != nil {
return ret, err
}
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
index 0f3d928..23b0952 100644
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
+++ b/vendor/github.com/shirou/gopsutil/cpu/cpu_linux.go
@@ -20,7 +20,7 @@ func init() {
if err != nil {
return
}
- out, err := invoke.Command(getconf, "CLK_TCK")
+ out, err := invoke.CommandWithContext(context.Background(), getconf, "CLK_TCK")
// ignore errors
if err == nil {
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
diff --git a/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go b/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
index 0899f41..117fd90 100644
--- a/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/cpu/cpu_solaris.go
@@ -47,7 +47,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
if err != nil {
return nil, fmt.Errorf("cannot find psrinfo: %s", err)
}
- psrInfoOut, err := invoke.Command(psrInfo, "-p", "-v")
+ psrInfoOut, err := invoke.CommandWithContext(ctx, psrInfo, "-p", "-v")
if err != nil {
return nil, fmt.Errorf("cannot execute psrinfo: %s", err)
}
@@ -56,7 +56,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
if err != nil {
return nil, fmt.Errorf("cannot find isainfo: %s", err)
}
- isaInfoOut, err := invoke.Command(isaInfo, "-b", "-v")
+ isaInfoOut, err := invoke.CommandWithContext(ctx, isaInfo, "-b", "-v")
if err != nil {
return nil, fmt.Errorf("cannot execute isainfo: %s", err)
}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk.go b/vendor/github.com/shirou/gopsutil/disk/disk.go
index a2c4720..1c31047 100644
--- a/vendor/github.com/shirou/gopsutil/disk/disk.go
+++ b/vendor/github.com/shirou/gopsutil/disk/disk.go
@@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common"
)
-var invoke common.Invoker
-
-func init() {
- invoke = common.Invoke{}
-}
+var invoke common.Invoker = common.Invoke{}
type UsageStat struct {
Path string `json:"path"`
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go
index 82ffacb..f9fd09c 100644
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/disk/disk_darwin.go
@@ -22,7 +22,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
if err != nil {
return ret, err
}
- fs := make([]Statfs_t, count)
+ fs := make([]Statfs, count)
_, err = Getfsstat(fs, MntWait)
for _, stat := range fs {
opts := "rw"
@@ -92,16 +92,16 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro
return ret, nil
}
-func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
+func Getfsstat(buf []Statfs, flags int) (n int, err error) {
return GetfsstatWithContext(context.Background(), buf, flags)
}
-func GetfsstatWithContext(ctx context.Context, buf []Statfs_t, flags int) (n int, err error) {
+func GetfsstatWithContext(ctx context.Context, buf []Statfs, flags int) (n int, err error) {
var _p0 unsafe.Pointer
var bufsize uintptr
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
- bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
+ bufsize = unsafe.Sizeof(Statfs{}) * uintptr(len(buf))
}
r0, _, e1 := unix.Syscall(SYS_GETFSSTAT64, uintptr(_p0), bufsize, uintptr(flags))
n = int(r0)
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go
new file mode 100644
index 0000000..bd83a4a
--- /dev/null
+++ b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_386.go
@@ -0,0 +1,59 @@
+// +build darwin
+// +build 386
+
+package disk
+
+const (
+ MntWait = 1
+ MfsNameLen = 15 /* length of fs type name, not inc. nul */
+ MNameLen = 90 /* length of buffer for returned name */
+
+ MFSTYPENAMELEN = 16 /* length of fs type name including null */
+ MAXPATHLEN = 1024
+ MNAMELEN = MAXPATHLEN
+
+ SYS_GETFSSTAT64 = 347
+)
+
+type Fsid struct{ val [2]int32 } /* file system id type */
+type uid_t int32
+
+// sys/mount.h
+const (
+ MntReadOnly = 0x00000001 /* read only filesystem */
+ MntSynchronous = 0x00000002 /* filesystem written synchronously */
+ MntNoExec = 0x00000004 /* can't exec from filesystem */
+ MntNoSuid = 0x00000008 /* don't honor setuid bits on fs */
+ MntUnion = 0x00000020 /* union with underlying filesystem */
+ MntAsync = 0x00000040 /* filesystem written asynchronously */
+ MntSuidDir = 0x00100000 /* special handling of SUID on dirs */
+ MntSoftDep = 0x00200000 /* soft updates being done */
+ MntNoSymFollow = 0x00400000 /* do not follow symlinks */
+ MntGEOMJournal = 0x02000000 /* GEOM journal support enabled */
+ MntMultilabel = 0x04000000 /* MAC support for individual objects */
+ MntACLs = 0x08000000 /* ACL support enabled */
+ MntNoATime = 0x10000000 /* disable update of file access time */
+ MntClusterRead = 0x40000000 /* disable cluster read */
+ MntClusterWrite = 0x80000000 /* disable cluster write */
+ MntNFS4ACLs = 0x00000010
+)
+
+// https://github.com/golang/go/blob/master/src/syscall/ztypes_darwin_386.go#L82
+type Statfs struct {
+ Bsize uint32
+ Iosize int32
+ Blocks uint64
+ Bfree uint64
+ Bavail uint64
+ Files uint64
+ Ffree uint64
+ Fsid Fsid
+ Owner uint32
+ Type uint32
+ Flags uint32
+ Fssubtype uint32
+ Fstypename [16]int8
+ Mntonname [1024]int8
+ Mntfromname [1024]int8
+ Reserved [8]uint32
+}
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go
index f58e213..ec40a75 100644
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go
+++ b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_amd64.go
@@ -38,7 +38,7 @@ const (
MntNFS4ACLs = 0x00000010
)
-type Statfs_t struct {
+type Statfs struct {
Bsize uint32
Iosize int32
Blocks uint64
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go
index 52bcf4c..0e3f670 100644
--- a/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go
+++ b/vendor/github.com/shirou/gopsutil/disk/disk_darwin_arm64.go
@@ -38,7 +38,7 @@ const (
MntNFS4ACLs = 0x00000010
)
-type Statfs_t struct {
+type Statfs struct {
Bsize uint32
Iosize int32
Blocks uint64
diff --git a/vendor/github.com/shirou/gopsutil/disk/disk_linux.go b/vendor/github.com/shirou/gopsutil/disk/disk_linux.go
index f5eb526..46904e3 100644
--- a/vendor/github.com/shirou/gopsutil/disk/disk_linux.go
+++ b/vendor/github.com/shirou/gopsutil/disk/disk_linux.go
@@ -388,7 +388,7 @@ func GetDiskSerialNumberWithContext(ctx context.Context, name string) string {
return ""
}
- out, err := invoke.Command(udevadm, "info", "--query=property", n)
+ out, err := invoke.CommandWithContext(ctx, udevadm, "info", "--query=property", n)
// does not return error, just an empty string
if err != nil {
diff --git a/vendor/github.com/shirou/gopsutil/host/host.go b/vendor/github.com/shirou/gopsutil/host/host.go
index a256a6c..1e9e9bb 100644
--- a/vendor/github.com/shirou/gopsutil/host/host.go
+++ b/vendor/github.com/shirou/gopsutil/host/host.go
@@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common"
)
-var invoke common.Invoker
-
-func init() {
- invoke = common.Invoke{}
-}
+var invoke common.Invoker = common.Invoke{}
// A HostInfoStat describes the host status.
// This is not in the psutil but it useful.
diff --git a/vendor/github.com/shirou/gopsutil/host/host_darwin.go b/vendor/github.com/shirou/gopsutil/host/host_darwin.go
index c82d990..acefc2f 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_darwin.go
@@ -40,7 +40,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
uname, err := exec.LookPath("uname")
if err == nil {
- out, err := invoke.Command(uname, "-r")
+ out, err := invoke.CommandWithContext(ctx, uname, "-r")
if err == nil {
ret.KernelVersion = strings.ToLower(strings.TrimSpace(string(out)))
}
@@ -70,7 +70,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
ret.Procs = uint64(len(procs))
}
- values, err := common.DoSysctrl("kern.uuid")
+ values, err := common.DoSysctrlWithContext(ctx, "kern.uuid")
if err == nil && len(values) == 1 && values[0] != "" {
ret.HostID = strings.ToLower(values[0])
}
@@ -90,7 +90,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
if t != 0 {
return t, nil
}
- values, err := common.DoSysctrl("kern.boottime")
+ values, err := common.DoSysctrlWithContext(ctx, "kern.boottime")
if err != nil {
return 0, err
}
@@ -188,12 +188,12 @@ func PlatformInformationWithContext(ctx context.Context) (string, string, string
return "", "", "", err
}
- out, err := invoke.Command(uname, "-s")
+ out, err := invoke.CommandWithContext(ctx, uname, "-s")
if err == nil {
platform = strings.ToLower(strings.TrimSpace(string(out)))
}
- out, err = invoke.Command(sw_vers, "-productVersion")
+ out, err = invoke.CommandWithContext(ctx, sw_vers, "-productVersion")
if err == nil {
pver = strings.ToLower(strings.TrimSpace(string(out)))
}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_fallback.go b/vendor/github.com/shirou/gopsutil/host/host_fallback.go
index f6537a9..e80d7ea 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_fallback.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_fallback.go
@@ -55,3 +55,11 @@ func KernelVersion() (string, error) {
func KernelVersionWithContext(ctx context.Context) (string, error) {
return "", common.ErrNotImplementedError
}
+
+func PlatformInformation() (string, string, string, error) {
+ return PlatformInformationWithContext(context.Background())
+}
+
+func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
+ return "", "", "", common.ErrNotImplementedError
+}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go b/vendor/github.com/shirou/gopsutil/host/host_freebsd.go
index 2f51c31..00a8519 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_freebsd.go
@@ -8,7 +8,6 @@ import (
"encoding/binary"
"io/ioutil"
"os"
- "os/exec"
"runtime"
"strings"
"sync/atomic"
@@ -168,25 +167,17 @@ func PlatformInformation() (string, string, string, error) {
}
func PlatformInformationWithContext(ctx context.Context) (string, string, string, error) {
- platform := ""
- family := ""
- version := ""
- uname, err := exec.LookPath("uname")
+ platform, err := unix.Sysctl("kern.ostype")
if err != nil {
return "", "", "", err
}
- out, err := invoke.Command(uname, "-s")
- if err == nil {
- platform = strings.ToLower(strings.TrimSpace(string(out)))
- }
-
- out, err = invoke.Command(uname, "-r")
- if err == nil {
- version = strings.ToLower(strings.TrimSpace(string(out)))
+ version, err := unix.Sysctl("kern.osrelease")
+ if err != nil {
+ return "", "", "", err
}
- return platform, family, version, nil
+ return strings.ToLower(platform), "", strings.ToLower(version), nil
}
func Virtualization() (string, string, error) {
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux.go b/vendor/github.com/shirou/gopsutil/host/host_linux.go
index 5324258..0e09f15 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_linux.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_linux.go
@@ -109,10 +109,14 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
if err != nil {
return 0, err
}
+
statFile := "stat"
if system == "lxc" && role == "guest" {
// if lxc, /proc/uptime is used.
statFile = "uptime"
+ } else if system == "docker" && role == "guest" {
+ // also docker, guest
+ statFile = "uptime"
}
filename := common.HostProc(statFile)
@@ -120,20 +124,35 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
if err != nil {
return 0, err
}
- for _, line := range lines {
- if strings.HasPrefix(line, "btime") {
- f := strings.Fields(line)
- if len(f) != 2 {
- return 0, fmt.Errorf("wrong btime format")
- }
- b, err := strconv.ParseInt(f[1], 10, 64)
- if err != nil {
- return 0, err
+
+ if statFile == "stat" {
+ for _, line := range lines {
+ if strings.HasPrefix(line, "btime") {
+ f := strings.Fields(line)
+ if len(f) != 2 {
+ return 0, fmt.Errorf("wrong btime format")
+ }
+ b, err := strconv.ParseInt(f[1], 10, 64)
+ if err != nil {
+ return 0, err
+ }
+ t = uint64(b)
+ atomic.StoreUint64(&cachedBootTime, t)
+ return t, nil
}
- t = uint64(b)
- atomic.StoreUint64(&cachedBootTime, t)
- return t, nil
}
+ } else if statFile == "uptime" {
+ if len(lines) != 1 {
+ return 0, fmt.Errorf("wrong uptime format")
+ }
+ f := strings.Fields(lines[0])
+ b, err := strconv.ParseFloat(f[0], 64)
+ if err != nil {
+ return 0, err
+ }
+ t = uint64(time.Now().Unix()) - uint64(b)
+ atomic.StoreUint64(&cachedBootTime, t)
+ return t, nil
}
return 0, fmt.Errorf("could not find btime")
diff --git a/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go b/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go
new file mode 100644
index 0000000..b0fca09
--- /dev/null
+++ b/vendor/github.com/shirou/gopsutil/host/host_linux_mips64.go
@@ -0,0 +1,43 @@
+// Created by cgo -godefs - DO NOT EDIT
+// cgo -godefs types_linux.go
+
+package host
+
+const (
+ sizeofPtr = 0x4
+ sizeofShort = 0x2
+ sizeofInt = 0x4
+ sizeofLong = 0x4
+ sizeofLongLong = 0x8
+ sizeOfUtmp = 0x180
+)
+
+type (
+ _C_short int16
+ _C_int int32
+ _C_long int32
+ _C_long_long int64
+)
+
+type utmp struct {
+ Type int16
+ Pad_cgo_0 [2]byte
+ Pid int32
+ Line [32]int8
+ Id [4]int8
+ User [32]int8
+ Host [256]int8
+ Exit exit_status
+ Session int32
+ Tv timeval
+ Addr_v6 [4]int32
+ X__unused [20]int8
+}
+type exit_status struct {
+ Termination int16
+ Exit int16
+}
+type timeval struct {
+ Sec int32
+ Usec int32
+}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_openbsd.go b/vendor/github.com/shirou/gopsutil/host/host_openbsd.go
index 83c2f7d..2ad64d7 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_openbsd.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_openbsd.go
@@ -113,12 +113,12 @@ func PlatformInformationWithContext(ctx context.Context) (string, string, string
return "", "", "", err
}
- out, err := invoke.Command(uname, "-s")
+ out, err := invoke.CommandWithContext(ctx, uname, "-s")
if err == nil {
platform = strings.ToLower(strings.TrimSpace(string(out)))
}
- out, err = invoke.Command(uname, "-r")
+ out, err = invoke.CommandWithContext(ctx, uname, "-r")
if err == nil {
version = strings.ToLower(strings.TrimSpace(string(out)))
}
diff --git a/vendor/github.com/shirou/gopsutil/host/host_solaris.go b/vendor/github.com/shirou/gopsutil/host/host_solaris.go
index 2560c06..bb83bfc 100644
--- a/vendor/github.com/shirou/gopsutil/host/host_solaris.go
+++ b/vendor/github.com/shirou/gopsutil/host/host_solaris.go
@@ -38,7 +38,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
return nil, err
}
- out, err := invoke.Command(uname, "-srv")
+ out, err := invoke.CommandWithContext(ctx, uname, "-srv")
if err != nil {
return nil, err
}
@@ -87,7 +87,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
// If everything works, use the current zone ID as the HostID if present.
zonename, err := exec.LookPath("/usr/bin/zonename")
if err == nil {
- out, err := invoke.Command(zonename)
+ out, err := invoke.CommandWithContext(ctx, zonename)
if err == nil {
sc := bufio.NewScanner(bytes.NewReader(out))
for sc.Scan() {
@@ -114,7 +114,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
if result.HostID == "" {
hostID, err := exec.LookPath("/usr/bin/hostid")
if err == nil {
- out, err := invoke.Command(hostID)
+ out, err := invoke.CommandWithContext(ctx, hostID)
if err == nil {
sc := bufio.NewScanner(bytes.NewReader(out))
for sc.Scan() {
@@ -156,7 +156,7 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
return 0, err
}
- out, err := invoke.Command(kstat, "-p", "unix:0:system_misc:boot_time")
+ out, err := invoke.CommandWithContext(ctx, kstat, "-p", "unix:0:system_misc:boot_time")
if err != nil {
return 0, err
}
@@ -220,7 +220,7 @@ func KernelVersionWithContext(ctx context.Context) (string, error) {
return "", err
}
- out, err := invoke.Command(uname, "-srv")
+ out, err := invoke.CommandWithContext(ctx, uname, "-srv")
if err != nil {
return "", err
}
@@ -231,3 +231,18 @@ func KernelVersionWithContext(ctx context.Context) (string, error) {
}
return "", fmt.Errorf("could not get kernel version")
}
+
+func PlatformInformation() (platform string, family string, version string, err error) {
+ return PlatformInformationWithContext(context.Background())
+}
+
+func PlatformInformationWithContext(ctx context.Context) (platform string, family string, version string, err error) {
+ /* This is not finished yet at all. Please contribute! */
+
+ version, err = KernelVersion()
+ if err != nil {
+ return "", "", "", err
+ }
+
+ return "solaris", "solaris", version, nil
+}
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common.go b/vendor/github.com/shirou/gopsutil/internal/common/common.go
index fcee6be..f9373ee 100644
--- a/vendor/github.com/shirou/gopsutil/internal/common/common.go
+++ b/vendor/github.com/shirou/gopsutil/internal/common/common.go
@@ -32,15 +32,19 @@ var (
type Invoker interface {
Command(string, ...string) ([]byte, error)
+ CommandWithContext(context.Context, string, ...string) ([]byte, error)
}
type Invoke struct{}
func (i Invoke) Command(name string, arg ...string) ([]byte, error) {
- ctxt, cancel := context.WithTimeout(context.Background(), Timeout)
+ ctx, cancel := context.WithTimeout(context.Background(), Timeout)
defer cancel()
+ return i.CommandWithContext(ctx, name, arg...)
+}
- cmd := exec.CommandContext(ctxt, name, arg...)
+func (i Invoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
+ cmd := exec.CommandContext(ctx, name, arg...)
var buf bytes.Buffer
cmd.Stdout = &buf
@@ -84,6 +88,10 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
}
+func (i FakeInvoke) CommandWithContext(ctx context.Context, name string, arg ...string) ([]byte, error) {
+ return i.Command(name, arg...)
+}
+
var ErrNotImplementedError = errors.New("not implemented yet")
// ReadLines reads contents from a file and splits them by new lines.
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go b/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
index 2b6d4c1..3e85cc0 100644
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
+++ b/vendor/github.com/shirou/gopsutil/internal/common/common_darwin.go
@@ -3,6 +3,7 @@
package common
import (
+ "context"
"os"
"os/exec"
"strings"
@@ -11,12 +12,12 @@ import (
"golang.org/x/sys/unix"
)
-func DoSysctrl(mib string) ([]string, error) {
+func DoSysctrlWithContext(ctx context.Context, mib string) ([]string, error) {
sysctl, err := exec.LookPath("/usr/sbin/sysctl")
if err != nil {
return []string{}, err
}
- cmd := exec.Command(sysctl, "-n", mib)
+ cmd := exec.CommandContext(ctx, sysctl, "-n", mib)
cmd.Env = getSysctrlEnv(os.Environ())
out, err := cmd.Output()
if err != nil {
diff --git a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go b/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
index cc934dd..750a592 100644
--- a/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
+++ b/vendor/github.com/shirou/gopsutil/internal/common/common_unix.go
@@ -3,12 +3,13 @@
package common
import (
+ "context"
"os/exec"
"strconv"
"strings"
)
-func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
+func CallLsofWithContext(ctx context.Context, invoke Invoker, pid int32, args ...string) ([]string, error) {
var cmd []string
if pid == 0 { // will get from all processes.
cmd = []string{"-a", "-n", "-P"}
@@ -20,7 +21,7 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
if err != nil {
return []string{}, err
}
- out, err := invoke.Command(lsof, cmd...)
+ out, err := invoke.CommandWithContext(ctx, lsof, cmd...)
if err != nil {
// if no pid found, lsof returnes code 1.
if err.Error() == "exit status 1" && len(out) == 0 {
@@ -39,14 +40,14 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
return ret, nil
}
-func CallPgrep(invoke Invoker, pid int32) ([]int32, error) {
+func CallPgrepWithContext(ctx context.Context, invoke Invoker, pid int32) ([]int32, error) {
var cmd []string
cmd = []string{"-P", strconv.Itoa(int(pid))}
pgrep, err := exec.LookPath("pgrep")
if err != nil {
return []int32{}, err
}
- out, err := invoke.Command(pgrep, cmd...)
+ out, err := invoke.CommandWithContext(ctx, pgrep, cmd...)
if err != nil {
return []int32{}, err
}
diff --git a/vendor/github.com/shirou/gopsutil/mem/mem.go b/vendor/github.com/shirou/gopsutil/mem/mem.go
index 87dfb53..fd8337a 100644
--- a/vendor/github.com/shirou/gopsutil/mem/mem.go
+++ b/