Update vendor package shirou/gopsutil
* resolve #1392 * pull in the fix for shirou/gopsutil/#249 which updates the Linux driver for `cpu` to set `cpu.Mhz` to the maximum clock-speed of the CPU, if that's available
This commit is contained in:
parent
1269900973
commit
8efd355af7
|
@ -8,11 +8,19 @@ help: ## Show help
|
|||
|
||||
check: ## Check
|
||||
errcheck -ignore="Close|Run|Write" ./...
|
||||
golint ./... | egrep -v 'underscores|HttpOnly|should have comment|comment on exported|CamelCase|VM|UID'
|
||||
golint ./... | egrep -v 'underscores|HttpOnly|should have comment|comment on exported|CamelCase|VM|UID' && exit 1 || exit 0
|
||||
|
||||
BUILD_FAIL_PATTERN=grep -v "exec format error" | grep "build failed" && exit 1 || exit 0
|
||||
build_test: ## test only buildable
|
||||
GOOS=linux go test ./... | grep -v "exec format error"
|
||||
GOOS=freebsd go test ./... | grep -v "exec format error"
|
||||
CGO_ENABLED=0 GOOS=darwin go test ./... | grep -v "exec format error"
|
||||
CGO_ENABLED=1 GOOS=darwin go test ./... | grep -v "exec format error"
|
||||
GOOS=windows go test ./...| grep -v "exec format error"
|
||||
# Supported operating systems
|
||||
GOOS=linux go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=freebsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=windows go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
# Operating systems supported for building only (not implemented error if used)
|
||||
GOOS=dragonfly go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=netbsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=openbsd go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
GOOS=solaris go test ./... | $(BUILD_FAIL_PATTERN)
|
||||
@echo 'Successfully built on all known operating systems'
|
||||
|
|
|
@ -233,7 +233,7 @@ hostname x x x x
|
|||
proces x x
|
||||
os x x x x
|
||||
platform x x x
|
||||
platformfamiliy x x x
|
||||
platformfamily x x x
|
||||
virtualization x
|
||||
**CPU**
|
||||
VendorID x x x x
|
||||
|
|
|
@ -96,11 +96,11 @@ func Info() ([]InfoStat, error) {
|
|||
}
|
||||
|
||||
values := strings.Fields(string(out))
|
||||
mhz, err := strconv.ParseFloat(values[1], 64)
|
||||
hz, err := strconv.ParseFloat(values[1], 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
c.Mhz = mhz / 1000000.0
|
||||
c.Mhz = hz / 1000000.0
|
||||
|
||||
return append(ret, c), nil
|
||||
}
|
||||
|
|
|
@ -84,9 +84,11 @@ func perCPUTimes() ([]TimesStat, error) {
|
|||
}
|
||||
|
||||
func allCPUTimes() ([]TimesStat, error) {
|
||||
var count C.mach_msg_type_number_t = C.HOST_CPU_LOAD_INFO_COUNT
|
||||
var count C.mach_msg_type_number_t
|
||||
var cpuload C.host_cpu_load_info_data_t
|
||||
|
||||
count = C.HOST_CPU_LOAD_INFO_COUNT
|
||||
|
||||
status := C.host_statistics(C.host_t(C.mach_host_self()),
|
||||
C.HOST_CPU_LOAD_INFO,
|
||||
C.host_info_t(unsafe.Pointer(&cpuload)),
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
func Times(percpu bool) ([]TimesStat, error) {
|
||||
return []TimesStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Info() ([]InfoStat, error) {
|
||||
return []InfoStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Percent(interval time.Duration, percpu bool) ([]float64, error) {
|
||||
return []float64{}, common.ErrNotImplementedError
|
||||
}
|
|
@ -65,22 +65,39 @@ func sysCPUPath(cpu int32, relPath string) string {
|
|||
}
|
||||
|
||||
func finishCPUInfo(c *InfoStat) error {
|
||||
if c.Mhz == 0 {
|
||||
lines, err := common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
|
||||
if err == nil {
|
||||
value, err := strconv.ParseFloat(lines[0], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.Mhz = value
|
||||
}
|
||||
}
|
||||
var lines []string
|
||||
var err error
|
||||
var value float64
|
||||
|
||||
if len(c.CoreID) == 0 {
|
||||
lines, err := common.ReadLines(sysCPUPath(c.CPU, "topology/coreId"))
|
||||
lines, err = common.ReadLines(sysCPUPath(c.CPU, "topology/core_id"))
|
||||
if err == nil {
|
||||
c.CoreID = lines[0]
|
||||
}
|
||||
}
|
||||
|
||||
// override the value of c.Mhz with cpufreq/cpuinfo_max_freq regardless
|
||||
// of the value from /proc/cpuinfo because we want to report the maximum
|
||||
// clock-speed of the CPU for c.Mhz, matching the behaviour of Windows
|
||||
lines, err = common.ReadLines(sysCPUPath(c.CPU, "cpufreq/cpuinfo_max_freq"))
|
||||
// if we encounter errors below but has a value from parsing /proc/cpuinfo
|
||||
// then we ignore the error
|
||||
if err != nil {
|
||||
if c.Mhz == 0 {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
value, err = strconv.ParseFloat(lines[0], 64)
|
||||
if err != nil {
|
||||
if c.Mhz == 0 {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
c.Mhz = value/1000.0 // value is in kHz
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -136,11 +153,10 @@ func Info() ([]InfoStat, error) {
|
|||
}
|
||||
c.Stepping = int32(t)
|
||||
case "cpu MHz":
|
||||
t, err := strconv.ParseFloat(value, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
// treat this as the fallback value, thus we ignore error
|
||||
if t, err := strconv.ParseFloat(value, 64); err == nil {
|
||||
c.Mhz = t
|
||||
}
|
||||
c.Mhz = t
|
||||
case "cache size":
|
||||
t, err := strconv.ParseInt(strings.Replace(value, " KB", "", 1), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
@ -33,15 +33,18 @@ type PartitionStat struct {
|
|||
}
|
||||
|
||||
type IOCountersStat struct {
|
||||
ReadCount uint64 `json:"readCount"`
|
||||
WriteCount uint64 `json:"writeCount"`
|
||||
ReadBytes uint64 `json:"readBytes"`
|
||||
WriteBytes uint64 `json:"writeBytes"`
|
||||
ReadTime uint64 `json:"readTime"`
|
||||
WriteTime uint64 `json:"writeTime"`
|
||||
Name string `json:"name"`
|
||||
IoTime uint64 `json:"ioTime"`
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
ReadCount uint64 `json:"readCount"`
|
||||
MergedReadCount uint64 `json:"mergedReadCount"`
|
||||
WriteCount uint64 `json:"writeCount"`
|
||||
MergedWriteCount uint64 `json:"mergedWriteCount"`
|
||||
ReadBytes uint64 `json:"readBytes"`
|
||||
WriteBytes uint64 `json:"writeBytes"`
|
||||
ReadTime uint64 `json:"readTime"`
|
||||
WriteTime uint64 `json:"writeTime"`
|
||||
IopsInProgress uint64 `json:"iopsInProgress"`
|
||||
IoTime uint64 `json:"ioTime"`
|
||||
Name string `json:"name"`
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
}
|
||||
|
||||
func (d UsageStat) String() string {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package disk
|
||||
|
||||
import "github.com/shirou/gopsutil/internal/common"
|
||||
|
||||
func IOCounters() (map[string]IOCountersStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Partitions(all bool) ([]PartitionStat, error) {
|
||||
return []PartitionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Usage(path string) (*UsageStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
|
@ -124,8 +124,9 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
|||
WriteCount: d.Operations[DEVSTAT_WRITE],
|
||||
ReadBytes: d.Bytes[DEVSTAT_READ],
|
||||
WriteBytes: d.Bytes[DEVSTAT_WRITE],
|
||||
ReadTime: d.Duration[DEVSTAT_READ].Compute(),
|
||||
WriteTime: d.Duration[DEVSTAT_WRITE].Compute(),
|
||||
ReadTime: uint64(d.Duration[DEVSTAT_READ].Compute() * 1000),
|
||||
WriteTime: uint64(d.Duration[DEVSTAT_WRITE].Compute() * 1000),
|
||||
IoTime: uint64(d.Busy_time.Compute() * 1000),
|
||||
Name: name,
|
||||
}
|
||||
ret[name] = ds
|
||||
|
@ -134,9 +135,9 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
func (b Bintime) Compute() uint64 {
|
||||
func (b Bintime) Compute() float64 {
|
||||
BINTIME_SCALE := 5.42101086242752217003726400434970855712890625e-20
|
||||
return uint64(b.Sec) + b.Frac*uint64(BINTIME_SCALE)
|
||||
return float64(b.Sec) + float64(b.Frac)*BINTIME_SCALE
|
||||
}
|
||||
|
||||
// BT2LD(time) ((long double)(time).sec + (time).frac * BINTIME_SCALE)
|
||||
|
|
|
@ -292,6 +292,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
|||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
mergedReads, err := strconv.ParseUint((fields[4]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
rbytes, err := strconv.ParseUint((fields[5]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
|
@ -304,6 +308,10 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
|||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
mergedWrites, err := strconv.ParseUint((fields[8]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
wbytes, err := strconv.ParseUint((fields[9]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
|
@ -312,18 +320,25 @@ func IOCounters() (map[string]IOCountersStat, error) {
|
|||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
iopsInProgress, err := strconv.ParseUint((fields[11]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
iotime, err := strconv.ParseUint((fields[12]), 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
d := IOCountersStat{
|
||||
ReadBytes: rbytes * SectorSize,
|
||||
WriteBytes: wbytes * SectorSize,
|
||||
ReadCount: reads,
|
||||
WriteCount: writes,
|
||||
ReadTime: rtime,
|
||||
WriteTime: wtime,
|
||||
IoTime: iotime,
|
||||
ReadBytes: rbytes * SectorSize,
|
||||
WriteBytes: wbytes * SectorSize,
|
||||
ReadCount: reads,
|
||||
WriteCount: writes,
|
||||
MergedReadCount: mergedReads,
|
||||
MergedWriteCount: mergedWrites,
|
||||
ReadTime: rtime,
|
||||
WriteTime: wtime,
|
||||
IopsInProgress: iopsInProgress,
|
||||
IoTime: iotime,
|
||||
}
|
||||
if d == empty {
|
||||
continue
|
||||
|
|
|
@ -21,6 +21,10 @@ func Usage(path string) (*UsageStat, error) {
|
|||
InodesFree: (uint64(stat.Ffree)),
|
||||
}
|
||||
|
||||
// if could not get InodesTotal, return empty
|
||||
if ret.InodesTotal < ret.InodesFree {
|
||||
return ret, nil
|
||||
}
|
||||
ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
|
||||
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
|
||||
ret.Used = (uint64(stat.Blocks) - uint64(stat.Bfree)) * uint64(bsize)
|
||||
|
|
|
@ -18,14 +18,15 @@ type InfoStat struct {
|
|||
Hostname string `json:"hostname"`
|
||||
Uptime uint64 `json:"uptime"`
|
||||
BootTime uint64 `json:"bootTime"`
|
||||
Procs uint64 `json:"procs"` // number of processes
|
||||
OS string `json:"os"` // ex: freebsd, linux
|
||||
Platform string `json:"platform"` // ex: ubuntu, linuxmint
|
||||
PlatformFamily string `json:"platformFamily"` // ex: debian, rhel
|
||||
PlatformVersion string `json:"platformVersion"`
|
||||
Procs uint64 `json:"procs"` // number of processes
|
||||
OS string `json:"os"` // ex: freebsd, linux
|
||||
Platform string `json:"platform"` // ex: ubuntu, linuxmint
|
||||
PlatformFamily string `json:"platformFamily"` // ex: debian, rhel
|
||||
PlatformVersion string `json:"platformVersion"` // version of the complete OS
|
||||
KernelVersion string `json:"kernelVersion"` // version of the OS kernel (if available)
|
||||
VirtualizationSystem string `json:"virtualizationSystem"`
|
||||
VirtualizationRole string `json:"virtualizationRole"` // guest or host
|
||||
|
||||
HostID string `json:"hostid"` // ex: uuid
|
||||
}
|
||||
|
||||
type UserStat struct {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
)
|
||||
|
||||
// from utmpx.h
|
||||
|
@ -36,7 +37,9 @@ func Info() (*InfoStat, error) {
|
|||
ret.Platform = platform
|
||||
ret.PlatformFamily = family
|
||||
ret.PlatformVersion = version
|
||||
ret.KernelVersion = version
|
||||
}
|
||||
|
||||
system, role, err := Virtualization()
|
||||
if err == nil {
|
||||
ret.VirtualizationSystem = system
|
||||
|
@ -49,6 +52,16 @@ func Info() (*InfoStat, error) {
|
|||
ret.Uptime = uptime(boot)
|
||||
}
|
||||
|
||||
procs, err := process.Pids()
|
||||
if err == nil {
|
||||
ret.Procs = uint64(len(procs))
|
||||
}
|
||||
|
||||
values, err := common.DoSysctrl("kern.uuid")
|
||||
if err == nil && len(values) == 1 && values[0] != "" {
|
||||
ret.HostID = values[0]
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package host
|
||||
|
||||
import "github.com/shirou/gopsutil/internal/common"
|
||||
|
||||
func Info() (*InfoStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func BootTime() (uint64, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Uptime() (uint64, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Users() ([]UserStat, error) {
|
||||
return []UserStat{}, common.ErrNotImplementedError
|
||||
}
|
|
@ -15,6 +15,7 @@ import (
|
|||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
"github.com/shirou/gopsutil/process"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -39,7 +40,9 @@ func Info() (*InfoStat, error) {
|
|||
ret.Platform = platform
|
||||
ret.PlatformFamily = family
|
||||
ret.PlatformVersion = version
|
||||
ret.KernelVersion = version
|
||||
}
|
||||
|
||||
system, role, err := Virtualization()
|
||||
if err == nil {
|
||||
ret.VirtualizationSystem = system
|
||||
|
@ -52,6 +55,16 @@ func Info() (*InfoStat, error) {
|
|||
ret.Uptime = uptime(boot)
|
||||
}
|
||||
|
||||
procs, err := process.Pids()
|
||||
if err == nil {
|
||||
ret.Procs = uint64(len(procs))
|
||||
}
|
||||
|
||||
values, err := common.DoSysctrl("kern.hostuuid")
|
||||
if err == nil && len(values) == 1 && values[0] != "" {
|
||||
ret.HostID = values[0]
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
common "github.com/shirou/gopsutil/internal/common"
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
)
|
||||
|
||||
type LSB struct {
|
||||
|
@ -44,17 +44,43 @@ func Info() (*InfoStat, error) {
|
|||
ret.PlatformFamily = family
|
||||
ret.PlatformVersion = version
|
||||
}
|
||||
kernelVersion, err := KernelVersion()
|
||||
if err == nil {
|
||||
ret.KernelVersion = kernelVersion
|
||||
}
|
||||
|
||||
system, role, err := Virtualization()
|
||||
if err == nil {
|
||||
ret.VirtualizationSystem = system
|
||||
ret.VirtualizationRole = role
|
||||
}
|
||||
|
||||
boot, err := BootTime()
|
||||
if err == nil {
|
||||
ret.BootTime = boot
|
||||
ret.Uptime = uptime(boot)
|
||||
}
|
||||
|
||||
if numProcs, err := common.NumProcs(); err == nil {
|
||||
ret.Procs = numProcs
|
||||
}
|
||||
|
||||
sysProductUUID := common.HostSys("class/dmi/id/product_uuid")
|
||||
switch {
|
||||
case common.PathExists(sysProductUUID):
|
||||
lines, err := common.ReadLines(sysProductUUID)
|
||||
if err == nil && len(lines) > 0 && lines[0] != "" {
|
||||
ret.HostID = lines[0]
|
||||
break
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
values, err := common.DoSysctrl("kernel.random.boot_id")
|
||||
if err == nil && len(values) == 1 && values[0] != "" {
|
||||
ret.HostID = values[0]
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
@ -332,6 +358,22 @@ func PlatformInformation() (platform string, family string, version string, err
|
|||
|
||||
}
|
||||
|
||||
func KernelVersion() (version string, err error) {
|
||||
filename := common.HostProc("sys/kernel/osrelease")
|
||||
if common.PathExists(filename) {
|
||||
contents, err := common.ReadLines(filename)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(contents) > 0 {
|
||||
version = contents[0]
|
||||
}
|
||||
}
|
||||
|
||||
return version, nil
|
||||
}
|
||||
|
||||
func getRedhatishVersion(contents []string) string {
|
||||
c := strings.ToLower(strings.Join(contents, ""))
|
||||
|
||||
|
|
|
@ -54,12 +54,10 @@ func Info() (*InfoStat, error) {
|
|||
}
|
||||
|
||||
procs, err := process.Pids()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
if err == nil {
|
||||
ret.Procs = uint64(len(procs))
|
||||
}
|
||||
|
||||
ret.Procs = uint64(len(procs))
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
|
||||
var (
|
||||
Timeout = 3 * time.Second
|
||||
TimeoutErr = errors.New("Command timed out.")
|
||||
ErrTimeout = errors.New("Command timed out.")
|
||||
)
|
||||
|
||||
type Invoker interface {
|
||||
|
@ -338,6 +338,6 @@ func WaitTimeout(c *exec.Cmd, timeout time.Duration) error {
|
|||
}
|
||||
// wait for the command to return after killing it
|
||||
<-done
|
||||
return TimeoutErr
|
||||
return ErrTimeout
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,43 @@
|
|||
// +build linux
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
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()
|
||||
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
|
||||
}
|
||||
|
||||
func NumProcs() (uint64, error) {
|
||||
f, err := os.Open(HostProc())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
list, err := f.Readdir(-1)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(len(list)), err
|
||||
}
|
||||
|
|
|
@ -48,8 +48,12 @@ type VirtualMemoryStat struct {
|
|||
|
||||
// Linux specific numbers
|
||||
// https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html
|
||||
Buffers uint64 `json:"buffers"`
|
||||
Cached uint64 `json:"cached"`
|
||||
// https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
||||
Buffers uint64 `json:"buffers"`
|
||||
Cached uint64 `json:"cached"`
|
||||
Writeback uint64 `json:"writeback"`
|
||||
Dirty uint64 `json:"dirty"`
|
||||
WritebackTmp uint64 `json:"writebacktmp"`
|
||||
}
|
||||
|
||||
type SwapMemoryStat struct {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package mem
|
||||
|
||||
import "github.com/shirou/gopsutil/internal/common"
|
||||
|
||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func SwapMemory() (*SwapMemoryStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
|
@ -46,6 +46,12 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
|||
ret.Active = t * 1024
|
||||
case "Inactive":
|
||||
ret.Inactive = t * 1024
|
||||
case "Writeback":
|
||||
ret.Writeback = t * 1024
|
||||
case "WritebackTmp":
|
||||
ret.WritebackTmp = t * 1024
|
||||
case "Dirty":
|
||||
ret.Dirty = t * 1024
|
||||
}
|
||||
}
|
||||
if !memavail {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package net
|
||||
|
||||
import "github.com/shirou/gopsutil/internal/common"
|
||||
|
||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||
return []IOCountersStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func FilterCounters() ([]FilterStat, error) {
|
||||
return []FilterStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
|
||||
return []ProtoCountersStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func Connections(kind string) ([]ConnectionStat, error) {
|
||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
|
@ -10,6 +10,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/shirou/gopsutil/cpu"
|
||||
|
@ -105,7 +106,34 @@ func (p *Process) CmdlineSlice() ([]string, error) {
|
|||
return r[0], err
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
r, err := callPs("etime", p.Pid, false)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
elapsedSegments := strings.Split(strings.Replace(r[0][0], "-", ":", 1), ":")
|
||||
var elapsedDurations []time.Duration
|
||||
for i := len(elapsedSegments) - 1; i >= 0; i-- {
|
||||
p, err := strconv.ParseInt(elapsedSegments[i], 10, 0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
elapsedDurations = append(elapsedDurations, time.Duration(p))
|
||||
}
|
||||
|
||||
var elapsed time.Duration = time.Duration(elapsedDurations[0]) * time.Second
|
||||
if len(elapsedDurations) > 1 {
|
||||
elapsed += time.Duration(elapsedDurations[1]) * time.Minute
|
||||
}
|
||||
if len(elapsedDurations) > 2 {
|
||||
elapsed += time.Duration(elapsedDurations[2]) * time.Hour
|
||||
}
|
||||
if len(elapsedDurations) > 3 {
|
||||
elapsed += time.Duration(elapsedDurations[3]) * time.Hour * 24
|
||||
}
|
||||
|
||||
start := time.Now().Add(-elapsed)
|
||||
return start.Unix() * 1000, nil
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
// +build !darwin,!linux,!freebsd,!windows
|
||||
|
||||
package process
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/shirou/gopsutil/cpu"
|
||||
"github.com/shirou/gopsutil/internal/common"
|
||||
"github.com/shirou/gopsutil/net"
|
||||
)
|
||||
|
||||
type MemoryMapsStat struct {
|
||||
Path string `json:"path"`
|
||||
Rss uint64 `json:"rss"`
|
||||
Size uint64 `json:"size"`
|
||||
Pss uint64 `json:"pss"`
|
||||
SharedClean uint64 `json:"sharedClean"`
|
||||
SharedDirty uint64 `json:"sharedDirty"`
|
||||
PrivateClean uint64 `json:"privateClean"`
|
||||
PrivateDirty uint64 `json:"privateDirty"`
|
||||
Referenced uint64 `json:"referenced"`
|
||||
Anonymous uint64 `json:"anonymous"`
|
||||
Swap uint64 `json:"swap"`
|
||||
}
|
||||
|
||||
type MemoryInfoExStat struct {
|
||||
}
|
||||
|
||||
func Pids() ([]int32, error) {
|
||||
return []int32{}, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func NewProcess(pid int32) (*Process, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
|
||||
func (p *Process) Ppid() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Name() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Exe() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Cmdline() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) CmdlineSlice() ([]string, error) {
|
||||
return []string{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) CreateTime() (int64, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Cwd() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Parent() (*Process, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Status() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Uids() ([]int32, error) {
|
||||
return []int32{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Gids() ([]int32, error) {
|
||||
return []int32{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Terminal() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Nice() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOnice() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Rlimit() ([]RlimitStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IOCounters() (*IOCountersStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumFDs() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NumThreads() (int32, error) {
|
||||
return 0, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Threads() (map[string]string, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Times() (*cpu.TimesStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) CPUAffinity() ([]int32, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryInfoEx() (*MemoryInfoExStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Children() ([]*Process, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) OpenFiles() ([]OpenFilesStat, error) {
|
||||
return []OpenFilesStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
||||
return []net.ConnectionStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) NetIOCounters(pernic bool) ([]net.IOCountersStat, error) {
|
||||
return []net.IOCountersStat{}, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) IsRunning() (bool, error) {
|
||||
return true, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
||||
return nil, common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) SendSignal(sig syscall.Signal) error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Suspend() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Resume() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Terminate() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Kill() error {
|
||||
return common.ErrNotImplementedError
|
||||
}
|
||||
func (p *Process) Username() (string, error) {
|
||||
return "", common.ErrNotImplementedError
|
||||
}
|
|
@ -527,9 +527,9 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
|
|||
ret.ReadCount = t
|
||||
case "syscw":
|
||||
ret.WriteCount = t
|
||||
case "readBytes":
|
||||
case "read_bytes":
|
||||
ret.ReadBytes = t
|
||||
case "writeBytes":
|
||||
case "write_bytes":
|
||||
ret.WriteBytes = t
|
||||
}
|
||||
}
|
||||
|
|
|
@ -758,58 +758,52 @@
|
|||
"revisionTime": "2016-04-29T17:20:22Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "UkExAUfzi5jJ08QYurU223nLThM=",
|
||||
"checksumSHA1": "Y13016ky4eYYAcgajHFtgxkkoW8=",
|
||||
"path": "github.com/shirou/gopsutil",
|
||||
"revision": "2728d81cdef579d6ed88d2fd5c71e85aa83eaba8",
|
||||
"revisionTime": "2016-06-25T09:45:55Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "G1oy2AGv5pCnNL0hRfg+mlX4Uq4=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "ToLFWWpwBceipBQRASIxs36Glok=",
|
||||
"path": "github.com/shirou/gopsutil/cpu",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "x4HZyWURx/UwxHVrdaTGbTFd198=",
|
||||
"checksumSHA1": "NOh16yOqf+hH+0XMJp3uV1Kb9FA=",
|
||||
"path": "github.com/shirou/gopsutil/disk",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "tV0skuyoy255WiTlKjd24T+5DeU=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "h0VVpxfeH65DnrSUtatFdvDS+RU=",
|
||||
"path": "github.com/shirou/gopsutil/host",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "zJZyxS96XiEnDJSZkWwXtktziRY=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "UnT7JW8ZDcUVJUYOPBfW6SToB0k=",
|
||||
"path": "github.com/shirou/gopsutil/internal/common",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "LUipApIqOLcKbZfwXknNCifGles=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "icZu8CrEyx4utr0MSc8CfTgQ1tU=",
|
||||
"path": "github.com/shirou/gopsutil/mem",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "k57srhFXKSysrFdEh3b6oiO48hw=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "hk7C6mEL2gyz79NfGa/s8YxPMUE=",
|
||||
"path": "github.com/shirou/gopsutil/net",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "+m5V0QobB9gklJkz+zk0NvaSeOs=",
|
||||
"comment": "1.0.0-230-gf58654f",
|
||||
"checksumSHA1": "cjLXT38Rtk5H/Sx+05PEqU8ta5Y=",
|
||||
"path": "github.com/shirou/gopsutil/process",
|
||||
"revision": "5c1bfed85550640833e8bbf50156d114ba99fbf2",
|
||||
"revisionTime": "2016-06-17T08:26:08Z"
|
||||
"revision": "859c81da50839c6829da58c9e90e1fff1edd8194",
|
||||
"revisionTime": "2016-08-29T23:42:49Z"
|
||||
},
|
||||
{
|
||||
"path": "github.com/shirou/w32",
|
||||
|
|
Loading…
Reference in New Issue