From 45aeaebda5dd016be3983f1bf904b18053fa2deb Mon Sep 17 00:00:00 2001 From: marcospedreiro Date: Sun, 18 Nov 2018 22:30:47 -0800 Subject: [PATCH 1/4] test windows cpu.Time(true) returning time instead of percentages --- README.rst | 2 +- cpu/cpu.go | 2 +- cpu/cpu_darwin_nocgo.go | 2 +- cpu/cpu_fallback.go | 2 +- cpu/cpu_freebsd.go | 2 +- cpu/cpu_freebsd_test.go | 2 +- cpu/cpu_linux.go | 2 +- cpu/cpu_openbsd.go | 2 +- cpu/cpu_solaris.go | 2 +- cpu/cpu_windows.go | 23 +++++++++++++++++++---- disk/disk.go | 2 +- disk/disk_darwin.go | 2 +- disk/disk_darwin_cgo.go | 2 +- disk/disk_darwin_nocgo.go | 2 +- disk/disk_fallback.go | 2 +- disk/disk_freebsd.go | 2 +- disk/disk_linux.go | 2 +- disk/disk_openbsd.go | 2 +- disk/disk_solaris.go | 2 +- disk/disk_unix.go | 2 +- disk/disk_windows.go | 2 +- docker/docker.go | 4 ++-- docker/docker_linux.go | 4 ++-- docker/docker_notlinux.go | 4 ++-- host/host.go | 2 +- host/host_darwin.go | 4 ++-- host/host_fallback.go | 2 +- host/host_freebsd.go | 4 ++-- host/host_linux.go | 2 +- host/host_openbsd.go | 4 ++-- host/host_solaris.go | 2 +- host/host_windows.go | 6 +++--- load/load.go | 2 +- load/load_darwin.go | 2 +- load/load_fallback.go | 2 +- load/load_linux.go | 2 +- load/load_windows.go | 2 +- mem/mem.go | 2 +- mem/mem_darwin.go | 2 +- mem/mem_fallback.go | 2 +- mem/mem_linux.go | 2 +- mem/mem_openbsd.go | 2 +- mem/mem_solaris.go | 2 +- mem/mem_windows.go | 2 +- net/net.go | 2 +- net/net_fallback.go | 2 +- net/net_freebsd.go | 2 +- net/net_linux.go | 6 +++--- net/net_linux_test.go | 2 +- net/net_openbsd.go | 2 +- net/net_test.go | 2 +- net/net_unix.go | 2 +- net/net_windows.go | 2 +- process/process.go | 6 +++--- process/process_darwin.go | 6 +++--- process/process_fallback.go | 6 +++--- process/process_freebsd.go | 6 +++--- process/process_linux.go | 8 ++++---- process/process_openbsd.go | 8 ++++---- process/process_test.go | 2 +- process/process_windows.go | 6 +++--- 61 files changed, 105 insertions(+), 90 deletions(-) diff --git a/README.rst b/README.rst index 63f5f6948..521ead94d 100644 --- a/README.rst +++ b/README.rst @@ -61,7 +61,7 @@ Note: gopsutil v2 breaks compatibility. If you want to stay with compatibility, import ( "fmt" - "github.com/shirou/gopsutil/mem" + "github.com/marcospedreiro/gopsutil/mem" ) func main() { diff --git a/cpu/cpu.go b/cpu/cpu.go index ceaf77fee..9b989ec46 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -10,7 +10,7 @@ import ( "sync" "time" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) // TimesStat contains the amounts of time the CPU has spent performing different diff --git a/cpu/cpu_darwin_nocgo.go b/cpu/cpu_darwin_nocgo.go index 242b4a8e7..5a77940eb 100644 --- a/cpu/cpu_darwin_nocgo.go +++ b/cpu/cpu_darwin_nocgo.go @@ -3,7 +3,7 @@ package cpu -import "github.com/shirou/gopsutil/internal/common" +import "github.com/marcospedreiro/gopsutil/internal/common" func perCPUTimes() ([]TimesStat, error) { return []TimesStat{}, common.ErrNotImplementedError diff --git a/cpu/cpu_fallback.go b/cpu/cpu_fallback.go index e9e7ada2c..fde93d66e 100644 --- a/cpu/cpu_fallback.go +++ b/cpu/cpu_fallback.go @@ -5,7 +5,7 @@ package cpu import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Times(percpu bool) ([]TimesStat, error) { diff --git a/cpu/cpu_freebsd.go b/cpu/cpu_freebsd.go index b6c7186c7..4c6bd3757 100644 --- a/cpu/cpu_freebsd.go +++ b/cpu/cpu_freebsd.go @@ -10,7 +10,7 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_freebsd_test.go b/cpu/cpu_freebsd_test.go index c0ec73ca3..e2574cec6 100644 --- a/cpu/cpu_freebsd_test.go +++ b/cpu/cpu_freebsd_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func TestParseDmesgBoot(t *testing.T) { diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index 2fffe85b9..31a3d55ba 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var CPUTick = float64(100) diff --git a/cpu/cpu_openbsd.go b/cpu/cpu_openbsd.go index 82b920f66..1c358a62b 100644 --- a/cpu/cpu_openbsd.go +++ b/cpu/cpu_openbsd.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_solaris.go b/cpu/cpu_solaris.go index 117fd909d..4b6256552 100644 --- a/cpu/cpu_solaris.go +++ b/cpu/cpu_solaris.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var ClocksPerSec = float64(128) diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index 975c2cb86..ad31bd110 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -8,7 +8,7 @@ import ( "unsafe" "github.com/StackExchange/wmi" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/windows" ) @@ -38,6 +38,20 @@ type win32_PerfFormattedData_Counters_ProcessorInformation struct { DPCRate uint32 } +type win32_PerfRawData_Counters_ProcessorInformation struct { + Name string + PercentDPCTime uint64 + PercentIdleTime uint64 + PercentUserTime uint64 + PercentProcessorTime uint64 + PercentInterruptTime uint64 + PercentPriorityTime uint64 + PercentPrivilegedTime uint64 + InterruptsPerSec uint32 + ProcessorFrequency uint32 + DPCRate uint32 +} + // Win32_PerfFormattedData_PerfOS_System struct to have count of processes and processor queue length type Win32_PerfFormattedData_PerfOS_System struct { Processes uint32 @@ -119,13 +133,14 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { // PerfInfo returns the performance counter's instance value for ProcessorInformation. // Name property is the key by which overall, per cpu and per core metric is known. -func perfInfoWithContext(ctx context.Context) ([]win32_PerfFormattedData_Counters_ProcessorInformation, error) { - var ret []win32_PerfFormattedData_Counters_ProcessorInformation +func perfInfoWithContext(ctx context.Context) ([]win32_PerfRawData_Counters_ProcessorInformation, error) { + var ret []win32_PerfRawData_Counters_ProcessorInformation + // Win32_PerfRawData_Counters_ProcessorInformation q := wmi.CreateQuery(&ret, "WHERE NOT Name LIKE '%_Total'") err := common.WMIQueryWithContext(ctx, q, &ret) if err != nil { - return []win32_PerfFormattedData_Counters_ProcessorInformation{}, err + return []win32_PerfRawData_Counters_ProcessorInformation{}, err } return ret, err diff --git a/disk/disk.go b/disk/disk.go index 38d8a8f16..95f464546 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -3,7 +3,7 @@ package disk import ( "encoding/json" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 2b1d000db..0369eb98c 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -7,7 +7,7 @@ import ( "path" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_darwin_cgo.go b/disk/disk_darwin_cgo.go index 480e23770..7ab337638 100644 --- a/disk/disk_darwin_cgo.go +++ b/disk/disk_darwin_cgo.go @@ -31,7 +31,7 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_darwin_nocgo.go b/disk/disk_darwin_nocgo.go index fe76d83e5..efc30dfe9 100644 --- a/disk/disk_darwin_nocgo.go +++ b/disk/disk_darwin_nocgo.go @@ -6,7 +6,7 @@ package disk import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_fallback.go b/disk/disk_fallback.go index 22eb50794..eebd62c43 100644 --- a/disk/disk_fallback.go +++ b/disk/disk_fallback.go @@ -5,7 +5,7 @@ package disk import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 2e0966a51..1f898f32f 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -12,7 +12,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Partitions(all bool) ([]PartitionStat, error) { diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 1b10a384a..e7121b3c5 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -14,7 +14,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) const ( diff --git a/disk/disk_openbsd.go b/disk/disk_openbsd.go index 6fdf38632..c4d647ddf 100644 --- a/disk/disk_openbsd.go +++ b/disk/disk_openbsd.go @@ -9,7 +9,7 @@ import ( "path" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_solaris.go b/disk/disk_solaris.go index c66083577..4b645ca5c 100644 --- a/disk/disk_solaris.go +++ b/disk/disk_solaris.go @@ -10,7 +10,7 @@ import ( "os" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_unix.go b/disk/disk_unix.go index 9b499b528..e84190292 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -51,7 +51,7 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { ret.UsedPercent = 0 } else { // We don't use ret.Total to calculate percent. - // see https://github.com/shirou/gopsutil/issues/562 + // see https://github.com/marcospedreiro/gopsutil/issues/562 ret.UsedPercent = (float64(ret.Used) / float64(ret.Used+ret.Free)) * 100.0 } diff --git a/disk/disk_windows.go b/disk/disk_windows.go index 326bc1f42..0e57fe6c3 100644 --- a/disk/disk_windows.go +++ b/disk/disk_windows.go @@ -7,7 +7,7 @@ import ( "context" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/docker/docker.go b/docker/docker.go index 912f93319..d551b156d 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -4,8 +4,8 @@ import ( "encoding/json" "errors" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" ) var ErrDockerNotAvailable = errors.New("docker not available") diff --git a/docker/docker_linux.go b/docker/docker_linux.go index 3f5a36135..fad3707f6 100644 --- a/docker/docker_linux.go +++ b/docker/docker_linux.go @@ -11,8 +11,8 @@ import ( "strconv" "strings" - cpu "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" + cpu "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/docker/docker_notlinux.go b/docker/docker_notlinux.go index dde104c3a..0d4fddffc 100644 --- a/docker/docker_notlinux.go +++ b/docker/docker_notlinux.go @@ -5,8 +5,8 @@ package docker import ( "context" - cpu "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" + cpu "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/host/host.go b/host/host.go index 1e9e9bb68..94d7fa8c8 100644 --- a/host/host.go +++ b/host/host.go @@ -3,7 +3,7 @@ package host import ( "encoding/json" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/host/host_darwin.go b/host/host_darwin.go index 8241fc08b..206965e13 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -16,8 +16,8 @@ import ( "time" "unsafe" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/process" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/process" ) // from utmpx.h diff --git a/host/host_fallback.go b/host/host_fallback.go index e80d7ea34..072bbcafb 100644 --- a/host/host_fallback.go +++ b/host/host_fallback.go @@ -5,7 +5,7 @@ package host import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Info() (*InfoStat, error) { diff --git a/host/host_freebsd.go b/host/host_freebsd.go index 00a851906..1e34b98da 100644 --- a/host/host_freebsd.go +++ b/host/host_freebsd.go @@ -15,8 +15,8 @@ import ( "time" "unsafe" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/process" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/process" "golang.org/x/sys/unix" ) diff --git a/host/host_linux.go b/host/host_linux.go index 2c1ac6ba7..0c6021637 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -18,7 +18,7 @@ import ( "sync/atomic" "time" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) type LSB struct { diff --git a/host/host_openbsd.go b/host/host_openbsd.go index 2ad64d77f..89568d47e 100644 --- a/host/host_openbsd.go +++ b/host/host_openbsd.go @@ -15,8 +15,8 @@ import ( "time" "unsafe" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/process" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/process" ) const ( diff --git a/host/host_solaris.go b/host/host_solaris.go index bb83bfc9c..5e366a007 100644 --- a/host/host_solaris.go +++ b/host/host_solaris.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Info() (*InfoStat, error) { diff --git a/host/host_windows.go b/host/host_windows.go index d89e191b7..f0ec5a04e 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -15,8 +15,8 @@ import ( "unsafe" "github.com/StackExchange/wmi" - "github.com/shirou/gopsutil/internal/common" - process "github.com/shirou/gopsutil/process" + "github.com/marcospedreiro/gopsutil/internal/common" + process "github.com/marcospedreiro/gopsutil/process" "golang.org/x/sys/windows" ) @@ -102,7 +102,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) { } func getMachineGuid() (string, error) { - // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612 + // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/marcospedreiro/gopsutil/pull/312#issuecomment-277422612 // for rationale of using windows.RegOpenKeyEx/RegQueryValueEx instead of registry.OpenKey/GetStringValue var h windows.Handle err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, windows.StringToUTF16Ptr(`SOFTWARE\Microsoft\Cryptography`), 0, windows.KEY_READ|windows.KEY_WOW64_64KEY, &h) diff --git a/load/load.go b/load/load.go index 908588955..49e2b4bae 100644 --- a/load/load.go +++ b/load/load.go @@ -3,7 +3,7 @@ package load import ( "encoding/json" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/load/load_darwin.go b/load/load_darwin.go index cd7b74dfe..b4d377b56 100644 --- a/load/load_darwin.go +++ b/load/load_darwin.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_fallback.go b/load/load_fallback.go index 1e3ade0ad..cd4f1821f 100644 --- a/load/load_fallback.go +++ b/load/load_fallback.go @@ -5,7 +5,7 @@ package load import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_linux.go b/load/load_linux.go index 63c26a2e2..f8cf3d53c 100644 --- a/load/load_linux.go +++ b/load/load_linux.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_windows.go b/load/load_windows.go index 42968b3bc..32e4e2134 100644 --- a/load/load_windows.go +++ b/load/load_windows.go @@ -5,7 +5,7 @@ package load import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/mem/mem.go b/mem/mem.go index e5056627e..cfaa56a7f 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -3,7 +3,7 @@ package mem import ( "encoding/json" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index 4fe7009b3..3c1f3bbba 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_fallback.go b/mem/mem_fallback.go index 2a0fd45b3..4bda29542 100644 --- a/mem/mem_fallback.go +++ b/mem/mem_fallback.go @@ -5,7 +5,7 @@ package mem import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func VirtualMemory() (*VirtualMemoryStat, error) { diff --git a/mem/mem_linux.go b/mem/mem_linux.go index fcc9a3f44..fbef03e5c 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_openbsd.go b/mem/mem_openbsd.go index 35472a326..aac01ea76 100644 --- a/mem/mem_openbsd.go +++ b/mem/mem_openbsd.go @@ -10,7 +10,7 @@ import ( "fmt" "os/exec" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func GetPageSize() (uint64, error) { diff --git a/mem/mem_solaris.go b/mem/mem_solaris.go index 0736bc41c..714f52ccc 100644 --- a/mem/mem_solaris.go +++ b/mem/mem_solaris.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) // VirtualMemory for Solaris is a minimal implementation which only returns diff --git a/mem/mem_windows.go b/mem/mem_windows.go index cfdf8bd1d..21170f0b6 100644 --- a/mem/mem_windows.go +++ b/mem/mem_windows.go @@ -6,7 +6,7 @@ import ( "context" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/net/net.go b/net/net.go index fce86c711..8e7abc16f 100644 --- a/net/net.go +++ b/net/net.go @@ -9,7 +9,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/net/net_fallback.go b/net/net_fallback.go index 7c5e632f8..af9f572f6 100644 --- a/net/net_fallback.go +++ b/net/net_fallback.go @@ -5,7 +5,7 @@ package net import ( "context" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_freebsd.go b/net/net_freebsd.go index ce0241576..a0627d5a0 100644 --- a/net/net_freebsd.go +++ b/net/net_freebsd.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_linux.go b/net/net_linux.go index 616c10ad2..631127081 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -15,7 +15,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) // NetIOCounters returnes network I/O statistics for every network @@ -661,7 +661,7 @@ func processInet(file string, kind netConnectionKindType, inodes map[string][]in // Read the contents of the /proc file with a single read sys call. // This minimizes duplicates in the returned connections // For more info: - // https://github.com/shirou/gopsutil/pull/361 + // https://github.com/marcospedreiro/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err @@ -722,7 +722,7 @@ func processUnix(file string, kind netConnectionKindType, inodes map[string][]in // Read the contents of the /proc file with a single read sys call. // This minimizes duplicates in the returned connections // For more info: - // https://github.com/shirou/gopsutil/pull/361 + // https://github.com/marcospedreiro/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err diff --git a/net/net_linux_test.go b/net/net_linux_test.go index 566a17b34..088aaa176 100644 --- a/net/net_linux_test.go +++ b/net/net_linux_test.go @@ -8,7 +8,7 @@ import ( "syscall" "testing" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "github.com/stretchr/testify/assert" ) diff --git a/net/net_openbsd.go b/net/net_openbsd.go index 3e74e8f3a..c4cc2579f 100644 --- a/net/net_openbsd.go +++ b/net/net_openbsd.go @@ -12,7 +12,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`) diff --git a/net/net_test.go b/net/net_test.go index 80f56afee..3d69fff99 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -6,7 +6,7 @@ import ( "runtime" "testing" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) func TestAddrString(t *testing.T) { diff --git a/net/net_unix.go b/net/net_unix.go index 4451b5457..7df3fddd7 100644 --- a/net/net_unix.go +++ b/net/net_unix.go @@ -6,7 +6,7 @@ import ( "context" "strings" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" ) // Return a list of network connections opened. diff --git a/net/net_windows.go b/net/net_windows.go index 61eb6ec20..220833b59 100644 --- a/net/net_windows.go +++ b/net/net_windows.go @@ -11,7 +11,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/process/process.go b/process/process.go index a4b24f46a..101890ad5 100644 --- a/process/process.go +++ b/process/process.go @@ -7,9 +7,9 @@ import ( "runtime" "time" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/mem" + "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/mem" ) var ( diff --git a/process/process_darwin.go b/process/process_darwin.go index 509ab3b53..594af3c54 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -13,9 +13,9 @@ import ( "time" "unsafe" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/net" + "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_fallback.go b/process/process_fallback.go index ca8b72f26..c4ac06cf8 100644 --- a/process/process_fallback.go +++ b/process/process_fallback.go @@ -6,9 +6,9 @@ import ( "context" "syscall" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/net" + "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/net" ) type MemoryMapsStat struct { diff --git a/process/process_freebsd.go b/process/process_freebsd.go index af2b3b179..595258884 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -8,9 +8,9 @@ import ( "encoding/binary" "strings" - cpu "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - net "github.com/shirou/gopsutil/net" + cpu "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + net "github.com/marcospedreiro/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_linux.go b/process/process_linux.go index f844101af..d33ff0c13 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -15,10 +15,10 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/host" - "github.com/shirou/gopsutil/internal/common" - "github.com/shirou/gopsutil/net" + "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/host" + "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_openbsd.go b/process/process_openbsd.go index b7b2cba00..1ce2c998d 100644 --- a/process/process_openbsd.go +++ b/process/process_openbsd.go @@ -10,10 +10,10 @@ import ( "strings" "unsafe" - cpu "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - mem "github.com/shirou/gopsutil/mem" - net "github.com/shirou/gopsutil/net" + cpu "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + mem "github.com/marcospedreiro/gopsutil/mem" + net "github.com/marcospedreiro/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_test.go b/process/process_test.go index a95efc230..0f3c4ac88 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/internal/common" + "github.com/marcospedreiro/gopsutil/internal/common" "github.com/stretchr/testify/assert" ) diff --git a/process/process_windows.go b/process/process_windows.go index 82aed37e3..9443808a0 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -12,9 +12,9 @@ import ( "unsafe" "github.com/StackExchange/wmi" - cpu "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/internal/common" - net "github.com/shirou/gopsutil/net" + cpu "github.com/marcospedreiro/gopsutil/cpu" + "github.com/marcospedreiro/gopsutil/internal/common" + net "github.com/marcospedreiro/gopsutil/net" "github.com/shirou/w32" "golang.org/x/sys/windows" ) From 3cc34ebf184b8c3f7edf6c06f93440a3f2443536 Mon Sep 17 00:00:00 2001 From: marcospedreiro Date: Mon, 19 Nov 2018 21:51:27 -0800 Subject: [PATCH 2/4] windows cpu time (true) should return cpu time not percentages --- cpu/cpu_test.go | 38 ++++++++++++++++++++++++++++++++++++++ cpu/cpu_windows.go | 28 ++++++++-------------------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/cpu/cpu_test.go b/cpu/cpu_test.go index 6082ffcc5..a756404ee 100644 --- a/cpu/cpu_test.go +++ b/cpu/cpu_test.go @@ -22,6 +22,44 @@ func TestCpu_times(t *testing.T) { t.Errorf("could not get CPU User: %v", vv) } } + + // test sum of per cpu stats is within margin of error for cpu total stats + cpuTotal, err := Times(false) + if err != nil { + t.Errorf("error %v", err) + } + if len(cpuTotal) == 0 { + t.Error("could not get CPUs ", err) + } + perCPU, err := Times(true) + if err != nil { + t.Errorf("error %v", err) + } + if len(perCPU) == 0 { + t.Error("could not get CPUs ", err) + } + var perCPUUserTimeSum float64 + var perCPUSystemTimeSum float64 + var perCPUIdleTimeSum float64 + for _, pc := range perCPU { + perCPUUserTimeSum += pc.User + perCPUSystemTimeSum += pc.System + perCPUIdleTimeSum += pc.Idle + } + margin := 2.0 + if !isWithinMargin(perCPUUserTimeSum, cpuTotal[0].User, margin) { + t.Errorf("perCPUUserTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUUserTimeSum, margin, cpuTotal[0].User) + } + if !isWithinMargin(perCPUSystemTimeSum, cpuTotal[0].System, margin) { + t.Errorf("perCPUSystemTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUSystemTimeSum, margin, cpuTotal[0].System) + } + if !isWithinMargin(perCPUIdleTimeSum, cpuTotal[0].Idle, margin) { + t.Errorf("perCPUIdleTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUIdleTimeSum, margin, cpuTotal[0].Idle) + } +} + +func isWithinMargin(n, source, margin float64) bool { + return n >= source-margin && n <= source+margin } func TestCpu_counts(t *testing.T) { diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index ad31bd110..9ea3ac000 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -23,21 +23,6 @@ type Win32_Processor struct { MaxClockSpeed uint32 } -// win32_PerfFormattedData_Counters_ProcessorInformation stores instance value of the perf counters -type win32_PerfFormattedData_Counters_ProcessorInformation struct { - Name string - PercentDPCTime uint64 - PercentIdleTime uint64 - PercentUserTime uint64 - PercentProcessorTime uint64 - PercentInterruptTime uint64 - PercentPriorityTime uint64 - PercentPrivilegedTime uint64 - InterruptsPerSec uint32 - ProcessorFrequency uint32 - DPCRate uint32 -} - type win32_PerfRawData_Counters_ProcessorInformation struct { Name string PercentDPCTime uint64 @@ -58,6 +43,10 @@ type Win32_PerfFormattedData_PerfOS_System struct { ProcessorQueueLength uint32 } +const ( + win32_TicksPerSecond = 10000000.0 +) + // Times returns times stat per cpu and combined for all CPUs func Times(percpu bool) ([]TimesStat, error) { return TimesWithContext(context.Background(), percpu) @@ -135,7 +124,6 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { // Name property is the key by which overall, per cpu and per core metric is known. func perfInfoWithContext(ctx context.Context) ([]win32_PerfRawData_Counters_ProcessorInformation, error) { var ret []win32_PerfRawData_Counters_ProcessorInformation - // Win32_PerfRawData_Counters_ProcessorInformation q := wmi.CreateQuery(&ret, "WHERE NOT Name LIKE '%_Total'") err := common.WMIQueryWithContext(ctx, q, &ret) @@ -172,10 +160,10 @@ func perCPUTimesWithContext(ctx context.Context) ([]TimesStat, error) { for _, v := range stats { c := TimesStat{ CPU: v.Name, - User: float64(v.PercentUserTime), - System: float64(v.PercentPrivilegedTime), - Idle: float64(v.PercentIdleTime), - Irq: float64(v.PercentInterruptTime), + User: float64(v.PercentUserTime) / win32_TicksPerSecond, + System: float64(v.PercentPrivilegedTime) / win32_TicksPerSecond, + Idle: float64(v.PercentIdleTime) / win32_TicksPerSecond, + Irq: float64(v.PercentInterruptTime) / win32_TicksPerSecond, } ret = append(ret, c) } From d47801b68ba13411bd45c2c61feceb0ed2ed0f74 Mon Sep 17 00:00:00 2001 From: marcospedreiro Date: Mon, 19 Nov 2018 22:06:05 -0800 Subject: [PATCH 3/4] revert imports --- README.rst | 2 +- cpu/cpu.go | 2 +- cpu/cpu_darwin_nocgo.go | 2 +- cpu/cpu_fallback.go | 2 +- cpu/cpu_freebsd.go | 2 +- cpu/cpu_freebsd_test.go | 2 +- cpu/cpu_linux.go | 2 +- cpu/cpu_openbsd.go | 2 +- cpu/cpu_solaris.go | 2 +- cpu/cpu_windows.go | 2 +- disk/disk.go | 2 +- disk/disk_darwin.go | 2 +- disk/disk_darwin_cgo.go | 2 +- disk/disk_darwin_nocgo.go | 2 +- disk/disk_fallback.go | 2 +- disk/disk_freebsd.go | 2 +- disk/disk_linux.go | 2 +- disk/disk_openbsd.go | 2 +- disk/disk_solaris.go | 2 +- disk/disk_unix.go | 2 +- disk/disk_windows.go | 2 +- docker/docker.go | 4 ++-- docker/docker_linux.go | 4 ++-- docker/docker_notlinux.go | 4 ++-- host/host.go | 2 +- host/host_darwin.go | 4 ++-- host/host_fallback.go | 2 +- host/host_freebsd.go | 4 ++-- host/host_linux.go | 2 +- host/host_openbsd.go | 4 ++-- host/host_solaris.go | 2 +- host/host_windows.go | 6 +++--- load/load.go | 2 +- load/load_darwin.go | 2 +- load/load_fallback.go | 2 +- load/load_linux.go | 2 +- load/load_windows.go | 2 +- mem/mem.go | 2 +- mem/mem_darwin.go | 2 +- mem/mem_fallback.go | 2 +- mem/mem_linux.go | 2 +- mem/mem_openbsd.go | 2 +- mem/mem_solaris.go | 2 +- mem/mem_windows.go | 2 +- net/net.go | 2 +- net/net_fallback.go | 2 +- net/net_freebsd.go | 2 +- net/net_linux.go | 6 +++--- net/net_linux_test.go | 2 +- net/net_openbsd.go | 2 +- net/net_test.go | 2 +- net/net_unix.go | 2 +- net/net_windows.go | 2 +- process/process.go | 6 +++--- process/process_darwin.go | 6 +++--- process/process_fallback.go | 6 +++--- process/process_freebsd.go | 6 +++--- process/process_linux.go | 8 ++++---- process/process_openbsd.go | 8 ++++---- process/process_test.go | 2 +- process/process_windows.go | 6 +++--- 61 files changed, 87 insertions(+), 87 deletions(-) diff --git a/README.rst b/README.rst index 521ead94d..63f5f6948 100644 --- a/README.rst +++ b/README.rst @@ -61,7 +61,7 @@ Note: gopsutil v2 breaks compatibility. If you want to stay with compatibility, import ( "fmt" - "github.com/marcospedreiro/gopsutil/mem" + "github.com/shirou/gopsutil/mem" ) func main() { diff --git a/cpu/cpu.go b/cpu/cpu.go index 9b989ec46..ceaf77fee 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -10,7 +10,7 @@ import ( "sync" "time" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) // TimesStat contains the amounts of time the CPU has spent performing different diff --git a/cpu/cpu_darwin_nocgo.go b/cpu/cpu_darwin_nocgo.go index 5a77940eb..242b4a8e7 100644 --- a/cpu/cpu_darwin_nocgo.go +++ b/cpu/cpu_darwin_nocgo.go @@ -3,7 +3,7 @@ package cpu -import "github.com/marcospedreiro/gopsutil/internal/common" +import "github.com/shirou/gopsutil/internal/common" func perCPUTimes() ([]TimesStat, error) { return []TimesStat{}, common.ErrNotImplementedError diff --git a/cpu/cpu_fallback.go b/cpu/cpu_fallback.go index fde93d66e..e9e7ada2c 100644 --- a/cpu/cpu_fallback.go +++ b/cpu/cpu_fallback.go @@ -5,7 +5,7 @@ package cpu import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Times(percpu bool) ([]TimesStat, error) { diff --git a/cpu/cpu_freebsd.go b/cpu/cpu_freebsd.go index 4c6bd3757..b6c7186c7 100644 --- a/cpu/cpu_freebsd.go +++ b/cpu/cpu_freebsd.go @@ -10,7 +10,7 @@ import ( "strings" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_freebsd_test.go b/cpu/cpu_freebsd_test.go index e2574cec6..c0ec73ca3 100644 --- a/cpu/cpu_freebsd_test.go +++ b/cpu/cpu_freebsd_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func TestParseDmesgBoot(t *testing.T) { diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index 31a3d55ba..2fffe85b9 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var CPUTick = float64(100) diff --git a/cpu/cpu_openbsd.go b/cpu/cpu_openbsd.go index 1c358a62b..82b920f66 100644 --- a/cpu/cpu_openbsd.go +++ b/cpu/cpu_openbsd.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_solaris.go b/cpu/cpu_solaris.go index 4b6256552..117fd909d 100644 --- a/cpu/cpu_solaris.go +++ b/cpu/cpu_solaris.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var ClocksPerSec = float64(128) diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index 9ea3ac000..3959212b1 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -8,7 +8,7 @@ import ( "unsafe" "github.com/StackExchange/wmi" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/disk/disk.go b/disk/disk.go index 95f464546..38d8a8f16 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -3,7 +3,7 @@ package disk import ( "encoding/json" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 0369eb98c..2b1d000db 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -7,7 +7,7 @@ import ( "path" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_darwin_cgo.go b/disk/disk_darwin_cgo.go index 7ab337638..480e23770 100644 --- a/disk/disk_darwin_cgo.go +++ b/disk/disk_darwin_cgo.go @@ -31,7 +31,7 @@ import ( "strings" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_darwin_nocgo.go b/disk/disk_darwin_nocgo.go index efc30dfe9..fe76d83e5 100644 --- a/disk/disk_darwin_nocgo.go +++ b/disk/disk_darwin_nocgo.go @@ -6,7 +6,7 @@ package disk import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_fallback.go b/disk/disk_fallback.go index eebd62c43..22eb50794 100644 --- a/disk/disk_fallback.go +++ b/disk/disk_fallback.go @@ -5,7 +5,7 @@ package disk import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func IOCounters(names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 1f898f32f..2e0966a51 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -12,7 +12,7 @@ import ( "golang.org/x/sys/unix" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Partitions(all bool) ([]PartitionStat, error) { diff --git a/disk/disk_linux.go b/disk/disk_linux.go index e7121b3c5..1b10a384a 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -14,7 +14,7 @@ import ( "golang.org/x/sys/unix" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) const ( diff --git a/disk/disk_openbsd.go b/disk/disk_openbsd.go index c4d647ddf..6fdf38632 100644 --- a/disk/disk_openbsd.go +++ b/disk/disk_openbsd.go @@ -9,7 +9,7 @@ import ( "path" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_solaris.go b/disk/disk_solaris.go index 4b645ca5c..c66083577 100644 --- a/disk/disk_solaris.go +++ b/disk/disk_solaris.go @@ -10,7 +10,7 @@ import ( "os" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_unix.go b/disk/disk_unix.go index e84190292..9b499b528 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -51,7 +51,7 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) { ret.UsedPercent = 0 } else { // We don't use ret.Total to calculate percent. - // see https://github.com/marcospedreiro/gopsutil/issues/562 + // see https://github.com/shirou/gopsutil/issues/562 ret.UsedPercent = (float64(ret.Used) / float64(ret.Used+ret.Free)) * 100.0 } diff --git a/disk/disk_windows.go b/disk/disk_windows.go index 0e57fe6c3..326bc1f42 100644 --- a/disk/disk_windows.go +++ b/disk/disk_windows.go @@ -7,7 +7,7 @@ import ( "context" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/docker/docker.go b/docker/docker.go index d551b156d..912f93319 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -4,8 +4,8 @@ import ( "encoding/json" "errors" - "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" ) var ErrDockerNotAvailable = errors.New("docker not available") diff --git a/docker/docker_linux.go b/docker/docker_linux.go index fad3707f6..3f5a36135 100644 --- a/docker/docker_linux.go +++ b/docker/docker_linux.go @@ -11,8 +11,8 @@ import ( "strconv" "strings" - cpu "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/docker/docker_notlinux.go b/docker/docker_notlinux.go index 0d4fddffc..dde104c3a 100644 --- a/docker/docker_notlinux.go +++ b/docker/docker_notlinux.go @@ -5,8 +5,8 @@ package docker import ( "context" - cpu "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/host/host.go b/host/host.go index 94d7fa8c8..1e9e9bb68 100644 --- a/host/host.go +++ b/host/host.go @@ -3,7 +3,7 @@ package host import ( "encoding/json" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/host/host_darwin.go b/host/host_darwin.go index 206965e13..8241fc08b 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -16,8 +16,8 @@ import ( "time" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/process" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/process" ) // from utmpx.h diff --git a/host/host_fallback.go b/host/host_fallback.go index 072bbcafb..e80d7ea34 100644 --- a/host/host_fallback.go +++ b/host/host_fallback.go @@ -5,7 +5,7 @@ package host import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Info() (*InfoStat, error) { diff --git a/host/host_freebsd.go b/host/host_freebsd.go index 1e34b98da..00a851906 100644 --- a/host/host_freebsd.go +++ b/host/host_freebsd.go @@ -15,8 +15,8 @@ import ( "time" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/process" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/process" "golang.org/x/sys/unix" ) diff --git a/host/host_linux.go b/host/host_linux.go index 0c6021637..2c1ac6ba7 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -18,7 +18,7 @@ import ( "sync/atomic" "time" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) type LSB struct { diff --git a/host/host_openbsd.go b/host/host_openbsd.go index 89568d47e..2ad64d77f 100644 --- a/host/host_openbsd.go +++ b/host/host_openbsd.go @@ -15,8 +15,8 @@ import ( "time" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/process" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/process" ) const ( diff --git a/host/host_solaris.go b/host/host_solaris.go index 5e366a007..bb83bfc9c 100644 --- a/host/host_solaris.go +++ b/host/host_solaris.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Info() (*InfoStat, error) { diff --git a/host/host_windows.go b/host/host_windows.go index f0ec5a04e..d89e191b7 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -15,8 +15,8 @@ import ( "unsafe" "github.com/StackExchange/wmi" - "github.com/marcospedreiro/gopsutil/internal/common" - process "github.com/marcospedreiro/gopsutil/process" + "github.com/shirou/gopsutil/internal/common" + process "github.com/shirou/gopsutil/process" "golang.org/x/sys/windows" ) @@ -102,7 +102,7 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) { } func getMachineGuid() (string, error) { - // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/marcospedreiro/gopsutil/pull/312#issuecomment-277422612 + // there has been reports of issues on 32bit using golang.org/x/sys/windows/registry, see https://github.com/shirou/gopsutil/pull/312#issuecomment-277422612 // for rationale of using windows.RegOpenKeyEx/RegQueryValueEx instead of registry.OpenKey/GetStringValue var h windows.Handle err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE, windows.StringToUTF16Ptr(`SOFTWARE\Microsoft\Cryptography`), 0, windows.KEY_READ|windows.KEY_WOW64_64KEY, &h) diff --git a/load/load.go b/load/load.go index 49e2b4bae..908588955 100644 --- a/load/load.go +++ b/load/load.go @@ -3,7 +3,7 @@ package load import ( "encoding/json" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/load/load_darwin.go b/load/load_darwin.go index b4d377b56..cd7b74dfe 100644 --- a/load/load_darwin.go +++ b/load/load_darwin.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_fallback.go b/load/load_fallback.go index cd4f1821f..1e3ade0ad 100644 --- a/load/load_fallback.go +++ b/load/load_fallback.go @@ -5,7 +5,7 @@ package load import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_linux.go b/load/load_linux.go index f8cf3d53c..63c26a2e2 100644 --- a/load/load_linux.go +++ b/load/load_linux.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_windows.go b/load/load_windows.go index 32e4e2134..42968b3bc 100644 --- a/load/load_windows.go +++ b/load/load_windows.go @@ -5,7 +5,7 @@ package load import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/mem/mem.go b/mem/mem.go index cfaa56a7f..e5056627e 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -3,7 +3,7 @@ package mem import ( "encoding/json" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index 3c1f3bbba..4fe7009b3 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_fallback.go b/mem/mem_fallback.go index 4bda29542..2a0fd45b3 100644 --- a/mem/mem_fallback.go +++ b/mem/mem_fallback.go @@ -5,7 +5,7 @@ package mem import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func VirtualMemory() (*VirtualMemoryStat, error) { diff --git a/mem/mem_linux.go b/mem/mem_linux.go index fbef03e5c..fcc9a3f44 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_openbsd.go b/mem/mem_openbsd.go index aac01ea76..35472a326 100644 --- a/mem/mem_openbsd.go +++ b/mem/mem_openbsd.go @@ -10,7 +10,7 @@ import ( "fmt" "os/exec" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func GetPageSize() (uint64, error) { diff --git a/mem/mem_solaris.go b/mem/mem_solaris.go index 714f52ccc..0736bc41c 100644 --- a/mem/mem_solaris.go +++ b/mem/mem_solaris.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) // VirtualMemory for Solaris is a minimal implementation which only returns diff --git a/mem/mem_windows.go b/mem/mem_windows.go index 21170f0b6..cfdf8bd1d 100644 --- a/mem/mem_windows.go +++ b/mem/mem_windows.go @@ -6,7 +6,7 @@ import ( "context" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/net/net.go b/net/net.go index 8e7abc16f..fce86c711 100644 --- a/net/net.go +++ b/net/net.go @@ -9,7 +9,7 @@ import ( "strings" "syscall" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/net/net_fallback.go b/net/net_fallback.go index af9f572f6..7c5e632f8 100644 --- a/net/net_fallback.go +++ b/net/net_fallback.go @@ -5,7 +5,7 @@ package net import ( "context" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_freebsd.go b/net/net_freebsd.go index a0627d5a0..ce0241576 100644 --- a/net/net_freebsd.go +++ b/net/net_freebsd.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_linux.go b/net/net_linux.go index 631127081..616c10ad2 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -15,7 +15,7 @@ import ( "strings" "syscall" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) // NetIOCounters returnes network I/O statistics for every network @@ -661,7 +661,7 @@ func processInet(file string, kind netConnectionKindType, inodes map[string][]in // Read the contents of the /proc file with a single read sys call. // This minimizes duplicates in the returned connections // For more info: - // https://github.com/marcospedreiro/gopsutil/pull/361 + // https://github.com/shirou/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err @@ -722,7 +722,7 @@ func processUnix(file string, kind netConnectionKindType, inodes map[string][]in // Read the contents of the /proc file with a single read sys call. // This minimizes duplicates in the returned connections // For more info: - // https://github.com/marcospedreiro/gopsutil/pull/361 + // https://github.com/shirou/gopsutil/pull/361 contents, err := ioutil.ReadFile(file) if err != nil { return nil, err diff --git a/net/net_linux_test.go b/net/net_linux_test.go index 088aaa176..566a17b34 100644 --- a/net/net_linux_test.go +++ b/net/net_linux_test.go @@ -8,7 +8,7 @@ import ( "syscall" "testing" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "github.com/stretchr/testify/assert" ) diff --git a/net/net_openbsd.go b/net/net_openbsd.go index c4cc2579f..3e74e8f3a 100644 --- a/net/net_openbsd.go +++ b/net/net_openbsd.go @@ -12,7 +12,7 @@ import ( "strings" "syscall" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`) diff --git a/net/net_test.go b/net/net_test.go index 3d69fff99..80f56afee 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -6,7 +6,7 @@ import ( "runtime" "testing" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) func TestAddrString(t *testing.T) { diff --git a/net/net_unix.go b/net/net_unix.go index 7df3fddd7..4451b5457 100644 --- a/net/net_unix.go +++ b/net/net_unix.go @@ -6,7 +6,7 @@ import ( "context" "strings" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" ) // Return a list of network connections opened. diff --git a/net/net_windows.go b/net/net_windows.go index 220833b59..61eb6ec20 100644 --- a/net/net_windows.go +++ b/net/net_windows.go @@ -11,7 +11,7 @@ import ( "syscall" "unsafe" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "golang.org/x/sys/windows" ) diff --git a/process/process.go b/process/process.go index 101890ad5..a4b24f46a 100644 --- a/process/process.go +++ b/process/process.go @@ -7,9 +7,9 @@ import ( "runtime" "time" - "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/mem" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/mem" ) var ( diff --git a/process/process_darwin.go b/process/process_darwin.go index 594af3c54..509ab3b53 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -13,9 +13,9 @@ import ( "time" "unsafe" - "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/net" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_fallback.go b/process/process_fallback.go index c4ac06cf8..ca8b72f26 100644 --- a/process/process_fallback.go +++ b/process/process_fallback.go @@ -6,9 +6,9 @@ import ( "context" "syscall" - "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/net" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/net" ) type MemoryMapsStat struct { diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 595258884..af2b3b179 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -8,9 +8,9 @@ import ( "encoding/binary" "strings" - cpu "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - net "github.com/marcospedreiro/gopsutil/net" + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + net "github.com/shirou/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_linux.go b/process/process_linux.go index d33ff0c13..f844101af 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -15,10 +15,10 @@ import ( "strconv" "strings" - "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/host" - "github.com/marcospedreiro/gopsutil/internal/common" - "github.com/marcospedreiro/gopsutil/net" + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/host" + "github.com/shirou/gopsutil/internal/common" + "github.com/shirou/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_openbsd.go b/process/process_openbsd.go index 1ce2c998d..b7b2cba00 100644 --- a/process/process_openbsd.go +++ b/process/process_openbsd.go @@ -10,10 +10,10 @@ import ( "strings" "unsafe" - cpu "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - mem "github.com/marcospedreiro/gopsutil/mem" - net "github.com/marcospedreiro/gopsutil/net" + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + mem "github.com/shirou/gopsutil/mem" + net "github.com/shirou/gopsutil/net" "golang.org/x/sys/unix" ) diff --git a/process/process_test.go b/process/process_test.go index 0f3c4ac88..a95efc230 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/marcospedreiro/gopsutil/internal/common" + "github.com/shirou/gopsutil/internal/common" "github.com/stretchr/testify/assert" ) diff --git a/process/process_windows.go b/process/process_windows.go index 9443808a0..82aed37e3 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -12,9 +12,9 @@ import ( "unsafe" "github.com/StackExchange/wmi" - cpu "github.com/marcospedreiro/gopsutil/cpu" - "github.com/marcospedreiro/gopsutil/internal/common" - net "github.com/marcospedreiro/gopsutil/net" + cpu "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/internal/common" + net "github.com/shirou/gopsutil/net" "github.com/shirou/w32" "golang.org/x/sys/windows" ) From f0ebb60b86bf08deb91845192e0b3892950c4739 Mon Sep 17 00:00:00 2001 From: marcospedreiro Date: Tue, 20 Nov 2018 13:25:17 -0800 Subject: [PATCH 4/4] handle pr comments: use assert.InEpsilon --- cpu/cpu_test.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/cpu/cpu_test.go b/cpu/cpu_test.go index a756404ee..2bff34034 100644 --- a/cpu/cpu_test.go +++ b/cpu/cpu_test.go @@ -6,6 +6,8 @@ import ( "runtime" "testing" "time" + + "github.com/stretchr/testify/assert" ) func TestCpu_times(t *testing.T) { @@ -47,19 +49,9 @@ func TestCpu_times(t *testing.T) { perCPUIdleTimeSum += pc.Idle } margin := 2.0 - if !isWithinMargin(perCPUUserTimeSum, cpuTotal[0].User, margin) { - t.Errorf("perCPUUserTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUUserTimeSum, margin, cpuTotal[0].User) - } - if !isWithinMargin(perCPUSystemTimeSum, cpuTotal[0].System, margin) { - t.Errorf("perCPUSystemTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUSystemTimeSum, margin, cpuTotal[0].System) - } - if !isWithinMargin(perCPUIdleTimeSum, cpuTotal[0].Idle, margin) { - t.Errorf("perCPUIdleTimeSum (%f) not within margin (%f) of cpuTotal (%f)", perCPUIdleTimeSum, margin, cpuTotal[0].Idle) - } -} - -func isWithinMargin(n, source, margin float64) bool { - return n >= source-margin && n <= source+margin + assert.InEpsilon(t, cpuTotal[0].User, perCPUUserTimeSum, margin) + assert.InEpsilon(t, cpuTotal[0].System, perCPUSystemTimeSum, margin) + assert.InEpsilon(t, cpuTotal[0].Idle, perCPUIdleTimeSum, margin) } func TestCpu_counts(t *testing.T) {