From fb3f2d89eaacef8f791cccd930b6d9e90d5ca7a0 Mon Sep 17 00:00:00 2001 From: Gustavo Serrano Diez Date: Mon, 25 Mar 2024 16:41:26 -0600 Subject: [PATCH] [1] Fix windows load avg (#1) Use the same logic as in Linux[^1] but with `NtQuerySystemInformation` Windows API call.[^2] [^1]: https://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html [^2]: see https://github.com/shirou/gopsutil/pull/1358 --- .golangci.yml | 2 +- README.md | 12 +- _tools/v3migration/v3Changes.md | 18 +-- _tools/v3migration/v3migration.go | 2 +- _tools/v3migration/v3migration.sh | 6 +- cpu/cpu.go | 2 +- cpu/cpu_aix_nocgo.go | 2 +- cpu/cpu_darwin_nocgo.go | 2 +- cpu/cpu_dragonfly.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_linux_test.go | 2 +- cpu/cpu_netbsd.go | 2 +- cpu/cpu_openbsd.go | 2 +- cpu/cpu_plan9.go | 2 +- cpu/cpu_test.go | 2 +- cpu/cpu_windows.go | 2 +- disk/disk.go | 2 +- disk/disk_aix.go | 2 +- disk/disk_aix_nocgo.go | 2 +- disk/disk_darwin.go | 4 +- 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_netbsd.go | 2 +- disk/disk_openbsd.go | 2 +- disk/disk_solaris.go | 2 +- disk/disk_test.go | 4 +- disk/disk_unix.go | 2 +- disk/disk_windows.go | 2 +- docker/docker.go | 4 +- docker/docker_linux.go | 4 +- docker/docker_notlinux.go | 2 +- go.mod | 12 +- go.sum | 8 -- host/host.go | 2 +- host/host_darwin.go | 4 +- host/host_darwin_nocgo.go | 2 +- host/host_fallback.go | 2 +- host/host_freebsd.go | 4 +- host/host_linux.go | 2 +- host/host_linux_test.go | 2 +- host/host_netbsd.go | 2 +- host/host_openbsd.go | 4 +- host/host_solaris.go | 2 +- host/host_test.go | 2 +- host/host_windows.go | 6 +- internal/common/common.go | 2 +- internal/common/common_test.go | 2 +- internal/common/common_windows.go | 212 ++++++++++++++++++++++++++++++ internal/common/sleep_test.go | 2 +- load/load.go | 2 +- load/load_aix_nocgo.go | 2 +- load/load_fallback.go | 2 +- load/load_linux.go | 2 +- load/load_test.go | 2 +- load/load_windows.go | 17 ++- mem/mem.go | 2 +- mem/mem_aix_nocgo.go | 2 +- mem/mem_darwin.go | 2 +- mem/mem_fallback.go | 2 +- mem/mem_freebsd.go | 2 +- mem/mem_linux.go | 2 +- mem/mem_openbsd.go | 2 +- mem/mem_plan9.go | 2 +- mem/mem_solaris.go | 2 +- mem/mem_test.go | 2 +- mem/mem_windows.go | 2 +- net/net.go | 2 +- net/net_aix.go | 2 +- net/net_aix_nocgo.go | 2 +- net/net_darwin.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_solaris.go | 2 +- net/net_test.go | 2 +- net/net_unix.go | 2 +- net/net_windows.go | 2 +- process/process.go | 8 +- process/process_bsd.go | 4 +- process/process_darwin.go | 6 +- process/process_darwin_cgo.go | 2 +- process/process_darwin_nocgo.go | 4 +- process/process_fallback.go | 6 +- process/process_freebsd.go | 8 +- process/process_linux.go | 8 +- process/process_openbsd.go | 10 +- process/process_plan9.go | 6 +- process/process_posix.go | 2 +- process/process_solaris.go | 6 +- process/process_test.go | 4 +- process/process_windows.go | 6 +- process/process_windows_32bit.go | 2 +- process/process_windows_64bit.go | 2 +- 101 files changed, 381 insertions(+), 166 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 170626bfd..9e6bbbc95 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -52,7 +52,7 @@ linters-settings: sections: - standard - default - - prefix(github.com/shirou) + - prefix(github.com/cloudsoda) gomodguard: blocked: modules: diff --git a/README.md b/README.md index fea8e7efd..b77d16a3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # gopsutil: psutil for golang -[![Test](https://github.com/shirou/gopsutil/actions/workflows/test.yml/badge.svg)](https://github.com/shirou/gopsutil/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/shirou/gopsutil/badge.svg?branch=master)](https://coveralls.io/github/shirou/gopsutil?branch=master) [![Go Reference](https://pkg.go.dev/badge/github.com/shirou/gopsutil/v3.svg)](https://pkg.go.dev/github.com/shirou/gopsutil/v3) [![Go Documentation](https://godocs.io/github.com/shirou/gopsutil/v3?status.svg)](https://godocs.io/github.com/shirou/gopsutil/v3) [![Calendar Versioning](https://img.shields.io/badge/calver-vMAJOR.YY.MM-22bfda.svg)](https://calver.org/) +[![Test](https://github.com/CloudSoda/gopsutil/actions/workflows/test.yml/badge.svg)](https://github.com/CloudSoda/gopsutil/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/CloudSoda/gopsutil/badge.svg?branch=master)](https://coveralls.io/github/CloudSoda/gopsutil?branch=master) [![Go Reference](https://pkg.go.dev/badge/github.com/CloudSoda/gopsutil/v3.svg)](https://pkg.go.dev/github.com/CloudSoda/gopsutil/v3) [![Go Documentation](https://godocs.io/github.com/CloudSoda/gopsutil/v3?status.svg)](https://godocs.io/github.com/CloudSoda/gopsutil/v3) [![Calendar Versioning](https://img.shields.io/badge/calver-vMAJOR.YY.MM-22bfda.svg)](https://calver.org/) This is a port of psutil (https://github.com/giampaolo/psutil). The challenge is porting all psutil functions on some architectures. @@ -52,8 +52,8 @@ package main import ( "fmt" - "github.com/shirou/gopsutil/v3/mem" - // "github.com/shirou/gopsutil/mem" // to use v2 + "github.com/CloudSoda/gopsutil/v3/mem" + // "github.com/CloudSoda/gopsutil/mem" // to use v2 ) func main() { @@ -98,7 +98,7 @@ You can set an alternative location to `/proc/N/mountinfo` by setting the ### Adding settings using `context` (from v3.23.6) -As of v3.23.6, it is now possible to pass a path location using `context`: import `"github.com/shirou/gopsutil/v3/common"` and pass a context with `common.EnvMap` set to `common.EnvKey`, and the location will be used within each function. +As of v3.23.6, it is now possible to pass a path location using `context`: import `"github.com/CloudSoda/gopsutil/v3/common"` and pass a context with `common.EnvMap` set to `common.EnvKey`, and the location will be used within each function. ``` ctx := context.WithValue(context.Background(), @@ -113,7 +113,7 @@ First priority is given to the value set in `context`, then the value from the e As of v3.24.1, it is now possible to cached some values. These values default to false, not cached. -Be very careful that enabling the cache may cause inconsistencies. For example, if you enable caching of boottime on Linux, be aware that unintended values may be returned if [the boottime is changed by NTP after booted](https://github.com/shirou/gopsutil/issues/1070#issuecomment-842512782). +Be very careful that enabling the cache may cause inconsistencies. For example, if you enable caching of boottime on Linux, be aware that unintended values may be returned if [the boottime is changed by NTP after booted](https://github.com/CloudSoda/gopsutil/issues/1070#issuecomment-842512782). - `host` - EnableBootTimeCache @@ -122,7 +122,7 @@ Be very careful that enabling the cache may cause inconsistencies. For example, ## Documentation -See https://pkg.go.dev/github.com/shirou/gopsutil/v3 or https://godocs.io/github.com/shirou/gopsutil/v3 +See https://pkg.go.dev/github.com/CloudSoda/gopsutil/v3 or https://godocs.io/github.com/CloudSoda/gopsutil/v3 ## Requirements diff --git a/_tools/v3migration/v3Changes.md b/_tools/v3migration/v3Changes.md index 1cd739e67..8d762ef79 100644 --- a/_tools/v3migration/v3Changes.md +++ b/_tools/v3migration/v3Changes.md @@ -2,17 +2,17 @@ - v3 is in the `v3` directory -- [process] RLimit is now uint64 ([#364](https://github.com/shirou/gopsutil/issues/364)) -- [process] Remove process.NetIOCounters ([#429](https://github.com/shirou/gopsutil/issues/429)) -- [docker] fix typo of memoryLimitInBbytes ([#464](https://github.com/shirou/gopsutil/issues/464)) -- [mem] VirtualMemoryStat JSON fields capitalization ([#545](https://github.com/shirou/gopsutil/issues/545)) +- [process] RLimit is now uint64 ([#364](https://github.com/CloudSoda/gopsutil/issues/364)) +- [process] Remove process.NetIOCounters ([#429](https://github.com/CloudSoda/gopsutil/issues/429)) +- [docker] fix typo of memoryLimitInBbytes ([#464](https://github.com/CloudSoda/gopsutil/issues/464)) +- [mem] VirtualMemoryStat JSON fields capitalization ([#545](https://github.com/CloudSoda/gopsutil/issues/545)) - various JSON field name and some of Variable name have been changed. see v3migration.sh - [all] various kind of platform dependent values/constants such as process.GetWin32Proc is now private. see v3migration.sh -- [process] process.Status() now returns []string. and status string is "Running", not just "R". defined in process.go. ([#596](https://github.com/shirou/gopsutil/issues/596)) -- [docker] `CgroupCPU()` now returns `*CgroupCPUStat` with Usage ([#590](https://github.com/shirou/gopsutil/issues/590) and [#581](https://github.com/shirou/gopsutil/issues/581)) -- [disk] `disk.Opts` is now string[], not string. (related to [#955](https://github.com/shirou/gopsutil/issues/955)) -- [host] Fixed temperature sensors detection in Linux ([#905](https://github.com/shirou/gopsutil/issues/905)) +- [process] process.Status() now returns []string. and status string is "Running", not just "R". defined in process.go. ([#596](https://github.com/CloudSoda/gopsutil/issues/596)) +- [docker] `CgroupCPU()` now returns `*CgroupCPUStat` with Usage ([#590](https://github.com/CloudSoda/gopsutil/issues/590) and [#581](https://github.com/CloudSoda/gopsutil/issues/581)) +- [disk] `disk.Opts` is now string[], not string. (related to [#955](https://github.com/CloudSoda/gopsutil/issues/955)) +- [host] Fixed temperature sensors detection in Linux ([#905](https://github.com/CloudSoda/gopsutil/issues/905)) - [disk] `GetDiskSerialNumber()` is now `SerialNumber()` and spread to all platforms - [disk] `GetLabel ()` is now `Label()` and spread to all platform -- [net] Change net.InterfaceStat.Addrs to InterfaceAddrList ([#226](https://github.com/shirou/gopsutil/issues/226)) +- [net] Change net.InterfaceStat.Addrs to InterfaceAddrList ([#226](https://github.com/CloudSoda/gopsutil/issues/226)) - [cpu] Removed windows-specific `ProcInfo()` diff --git a/_tools/v3migration/v3migration.go b/_tools/v3migration/v3migration.go index eb826f465..ea7fe3510 100644 --- a/_tools/v3migration/v3migration.go +++ b/_tools/v3migration/v3migration.go @@ -13,7 +13,7 @@ import ( "golang.org/x/tools/go/ast/astutil" ) -// https://github.com/shirou/gopsutil/issues/429 +// https://github.com/cloudsoda/gopsutil/issues/429 func issue429() error { f := func(filename string) error { fset := token.NewFileSet() diff --git a/_tools/v3migration/v3migration.sh b/_tools/v3migration/v3migration.sh index 39f65e899..ed0a14a04 100644 --- a/_tools/v3migration/v3migration.sh +++ b/_tools/v3migration/v3migration.sh @@ -3,7 +3,7 @@ set -eu # this scripts is used when migrating v2 to v3. -# usage: cd ${GOPATH}/src/github.com/shirou/gopsutil && bash tools/v3migration/v3migration.sh +# usage: cd ${GOPATH}/src/github.com/CloudSoda/gopsutil && bash tools/v3migration/v3migration.sh @@ -33,14 +33,14 @@ cd "${V3DIR}" go mod init ### change import path -find . -name "*.go" -print0 | xargs -0 -I@ sed -i 's|"github.com/shirou/gopsutil/|"github.com/shirou/gopsutil/v3/|g' @ +find . -name "*.go" -print0 | xargs -0 -I@ sed -i 's|"github.com/CloudSoda/gopsutil/|"github.com/CloudSoda/gopsutil/v3/|g' @ ############ Issues # #429 process.NetIOCounters is pointless on Linux ./v3migration "$(pwd)" 429 sed -i '/NetIOCounters/d' process/process.go -sed -i "/github.com\/shirou\/gopsutil\/v3\/net/d" process/process_bsd.go +sed -i "/github.com\/CloudSoda\/gopsutil\/v3\/net/d" process/process_bsd.go # #464 CgroupMem : fix typo and wrong file names diff --git a/cpu/cpu.go b/cpu/cpu.go index 83bc23d45..65a64889b 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // TimesStat contains the amounts of time the CPU has spent performing different diff --git a/cpu/cpu_aix_nocgo.go b/cpu/cpu_aix_nocgo.go index a77b4dbb7..7101966e2 100644 --- a/cpu/cpu_aix_nocgo.go +++ b/cpu/cpu_aix_nocgo.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) { diff --git a/cpu/cpu_darwin_nocgo.go b/cpu/cpu_darwin_nocgo.go index e067e99f9..fbcaa6312 100644 --- a/cpu/cpu_darwin_nocgo.go +++ b/cpu/cpu_darwin_nocgo.go @@ -3,7 +3,7 @@ package cpu -import "github.com/shirou/gopsutil/v3/internal/common" +import "github.com/cloudsoda/gopsutil/v3/internal/common" func perCPUTimes() ([]TimesStat, error) { return []TimesStat{}, common.ErrNotImplementedError diff --git a/cpu/cpu_dragonfly.go b/cpu/cpu_dragonfly.go index fef53e5dc..aba121cc5 100644 --- a/cpu/cpu_dragonfly.go +++ b/cpu/cpu_dragonfly.go @@ -10,7 +10,7 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_fallback.go b/cpu/cpu_fallback.go index 089f603c8..b90735122 100644 --- a/cpu/cpu_fallback.go +++ b/cpu/cpu_fallback.go @@ -7,7 +7,7 @@ import ( "context" "runtime" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func Times(percpu bool) ([]TimesStat, error) { diff --git a/cpu/cpu_freebsd.go b/cpu/cpu_freebsd.go index d3f47353c..8005eda9d 100644 --- a/cpu/cpu_freebsd.go +++ b/cpu/cpu_freebsd.go @@ -10,7 +10,7 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_freebsd_test.go b/cpu/cpu_freebsd_test.go index 27a709d31..8a4c45a9e 100644 --- a/cpu/cpu_freebsd_test.go +++ b/cpu/cpu_freebsd_test.go @@ -5,7 +5,7 @@ import ( "runtime" "testing" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func TestParseDmesgBoot(t *testing.T) { diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index da467e2dd..8d25b4923 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -13,7 +13,7 @@ import ( "github.com/tklauser/go-sysconf" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var ClocksPerSec = float64(100) diff --git a/cpu/cpu_linux_test.go b/cpu/cpu_linux_test.go index e06f30520..7f70fa5b2 100644 --- a/cpu/cpu_linux_test.go +++ b/cpu/cpu_linux_test.go @@ -93,7 +93,7 @@ func TestCPUCountsAgainstLscpu(t *testing.T) { } } -func TestCPUCountsLogicalAndroid_1037(t *testing.T) { // https://github.com/shirou/gopsutil/issues/1037 +func TestCPUCountsLogicalAndroid_1037(t *testing.T) { // https://github.com/cloudsoda/gopsutil/issues/1037 t.Setenv("HOST_PROC", "testdata/linux/1037/proc") count, err := Counts(true) diff --git a/cpu/cpu_netbsd.go b/cpu/cpu_netbsd.go index 1f66be342..43432a7de 100644 --- a/cpu/cpu_netbsd.go +++ b/cpu/cpu_netbsd.go @@ -9,7 +9,7 @@ import ( "runtime" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_openbsd.go b/cpu/cpu_openbsd.go index fe3329030..4e68424bb 100644 --- a/cpu/cpu_openbsd.go +++ b/cpu/cpu_openbsd.go @@ -9,7 +9,7 @@ import ( "runtime" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" ) diff --git a/cpu/cpu_plan9.go b/cpu/cpu_plan9.go index a2e99d8c0..fdb262b15 100644 --- a/cpu/cpu_plan9.go +++ b/cpu/cpu_plan9.go @@ -9,7 +9,7 @@ import ( "runtime" stats "github.com/lufia/plan9stats" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func Times(percpu bool) ([]TimesStat, error) { diff --git a/cpu/cpu_test.go b/cpu/cpu_test.go index 688660a1a..ce4834df9 100644 --- a/cpu/cpu_test.go +++ b/cpu/cpu_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/cpu/cpu_windows.go b/cpu/cpu_windows.go index e10612fd1..eec4887ab 100644 --- a/cpu/cpu_windows.go +++ b/cpu/cpu_windows.go @@ -8,7 +8,7 @@ import ( "fmt" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/yusufpapurcu/wmi" "golang.org/x/sys/windows" ) diff --git a/disk/disk.go b/disk/disk.go index 0d4b25345..c34b9d6e7 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/disk/disk_aix.go b/disk/disk_aix.go index bc71712ea..2e8ac009f 100644 --- a/disk/disk_aix.go +++ b/disk/disk_aix.go @@ -6,7 +6,7 @@ package disk import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_aix_nocgo.go b/disk/disk_aix_nocgo.go index 17e2b9c84..1cf346167 100644 --- a/disk/disk_aix_nocgo.go +++ b/disk/disk_aix_nocgo.go @@ -8,7 +8,7 @@ import ( "regexp" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 9362d9e5d..874fa7b45 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -8,7 +8,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // PartitionsWithContext returns disk partition. @@ -28,7 +28,7 @@ func PartitionsWithContext(ctx context.Context, all bool) ([]PartitionStat, erro // On 10.14, and possibly other OS versions, the actual count may // be less than from the first call. Truncate to the returned count // to prevent accessing uninitialized entries. - // https://github.com/shirou/gopsutil/issues/1390 + // https://github.com/cloudsoda/gopsutil/issues/1390 fs = fs[:count] for _, stat := range fs { opts := []string{"rw"} diff --git a/disk/disk_darwin_cgo.go b/disk/disk_darwin_cgo.go index 27c24c922..ef7653bfc 100644 --- a/disk/disk_darwin_cgo.go +++ b/disk/disk_darwin_cgo.go @@ -14,7 +14,7 @@ import "C" import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_darwin_nocgo.go b/disk/disk_darwin_nocgo.go index 1f099b7ca..a055c3dcf 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/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_fallback.go b/disk/disk_fallback.go index 36525f694..66b482633 100644 --- a/disk/disk_fallback.go +++ b/disk/disk_fallback.go @@ -6,7 +6,7 @@ package disk import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) { diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 9b53106c2..51667209f 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_linux.go b/disk/disk_linux.go index ada9f9e76..3ab73b4dc 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -16,7 +16,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) const ( diff --git a/disk/disk_netbsd.go b/disk/disk_netbsd.go index 5976efadb..e886bd2f3 100644 --- a/disk/disk_netbsd.go +++ b/disk/disk_netbsd.go @@ -7,7 +7,7 @@ import ( "context" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_openbsd.go b/disk/disk_openbsd.go index 81ff23994..30789b9b0 100644 --- a/disk/disk_openbsd.go +++ b/disk/disk_openbsd.go @@ -8,7 +8,7 @@ import ( "context" "encoding/binary" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_solaris.go b/disk/disk_solaris.go index 5d6ea8653..901eab35d 100644 --- a/disk/disk_solaris.go +++ b/disk/disk_solaris.go @@ -16,7 +16,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/disk/disk_test.go b/disk/disk_test.go index 5adae5ca3..5037288fc 100644 --- a/disk/disk_test.go +++ b/disk/disk_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { @@ -67,7 +67,7 @@ func TestDisk_io_counters(t *testing.T) { } } -// https://github.com/shirou/gopsutil/issues/560 regression test +// https://github.com/cloudsoda/gopsutil/issues/560 regression test func TestDisk_io_counters_concurrency_on_darwin_cgo(t *testing.T) { if runtime.GOOS != "darwin" { t.Skip("darwin only") diff --git a/disk/disk_unix.go b/disk/disk_unix.go index 1e7352408..310d47fa6 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -33,7 +33,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/cloudsoda/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 e17db3e5b..a5f06b4ee 100644 --- a/disk/disk_windows.go +++ b/disk/disk_windows.go @@ -10,7 +10,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/windows" "golang.org/x/sys/windows/registry" ) diff --git a/docker/docker.go b/docker/docker.go index dda7ba00a..3560e391c 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -4,8 +4,8 @@ import ( "encoding/json" "errors" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var ( diff --git a/docker/docker_linux.go b/docker/docker_linux.go index 4904874d0..20ce60581 100644 --- a/docker/docker_linux.go +++ b/docker/docker_linux.go @@ -13,8 +13,8 @@ import ( "strconv" "strings" - cpu "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" + cpu "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/docker/docker_notlinux.go b/docker/docker_notlinux.go index 434ca12aa..d02968837 100644 --- a/docker/docker_notlinux.go +++ b/docker/docker_notlinux.go @@ -6,7 +6,7 @@ package docker import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // GetDockerStat returns a list of Docker basic stats. diff --git a/go.mod b/go.mod index 4233d40ac..0841ea2e8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ -module github.com/shirou/gopsutil/v3 +module github.com/cloudsoda/gopsutil/v3 -go 1.15 +go 1.21 require ( github.com/google/go-cmp v0.6.0 @@ -13,4 +13,12 @@ require ( golang.org/x/sys v0.17.0 ) +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + retract v3.22.11 diff --git a/go.sum b/go.sum index 390501b5e..07dd300d9 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,8 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= @@ -17,11 +15,6 @@ github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFt github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= @@ -39,6 +32,5 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/host/host.go b/host/host.go index ee9486369..b6e9c4bef 100644 --- a/host/host.go +++ b/host/host.go @@ -8,7 +8,7 @@ import ( "runtime" "time" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) type Warnings = common.Warnings diff --git a/host/host_darwin.go b/host/host_darwin.go index 873ed4aee..a4ef89a6d 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -15,8 +15,8 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/process" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/process" ) // from utmpx.h diff --git a/host/host_darwin_nocgo.go b/host/host_darwin_nocgo.go index 6285ba94d..4e6c8cdc0 100644 --- a/host/host_darwin_nocgo.go +++ b/host/host_darwin_nocgo.go @@ -6,7 +6,7 @@ package host import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, error) { diff --git a/host/host_fallback.go b/host/host_fallback.go index a393ca15d..97af8bbbd 100644 --- a/host/host_fallback.go +++ b/host/host_fallback.go @@ -6,7 +6,7 @@ package host import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func HostIDWithContext(ctx context.Context) (string, error) { diff --git a/host/host_freebsd.go b/host/host_freebsd.go index 9a5382d39..a03aea417 100644 --- a/host/host_freebsd.go +++ b/host/host_freebsd.go @@ -13,8 +13,8 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/process" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/process" "golang.org/x/sys/unix" ) diff --git a/host/host_linux.go b/host/host_linux.go index 5d4c1a90f..f4f36d522 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -17,7 +17,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) type lsbStruct struct { diff --git a/host/host_linux_test.go b/host/host_linux_test.go index c114ec795..dc9014421 100644 --- a/host/host_linux_test.go +++ b/host/host_linux_test.go @@ -7,7 +7,7 @@ import ( "context" "testing" - "github.com/shirou/gopsutil/v3/common" + "github.com/cloudsoda/gopsutil/v3/common" ) func TestGetRedhatishVersion(t *testing.T) { diff --git a/host/host_netbsd.go b/host/host_netbsd.go index 488f1dfc2..a59c1eb1f 100644 --- a/host/host_netbsd.go +++ b/host/host_netbsd.go @@ -7,7 +7,7 @@ import ( "context" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/host/host_openbsd.go b/host/host_openbsd.go index 325015c23..c1b586f45 100644 --- a/host/host_openbsd.go +++ b/host/host_openbsd.go @@ -12,8 +12,8 @@ import ( "strings" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/process" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/process" "golang.org/x/sys/unix" ) diff --git a/host/host_solaris.go b/host/host_solaris.go index fef67f835..b695f8e53 100644 --- a/host/host_solaris.go +++ b/host/host_solaris.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func HostIDWithContext(ctx context.Context) (string, error) { diff --git a/host/host_test.go b/host/host_test.go index d3b75859e..944af4b15 100644 --- a/host/host_test.go +++ b/host/host_test.go @@ -7,7 +7,7 @@ import ( "sync" "testing" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/host/host_windows.go b/host/host_windows.go index b83ad6db1..abcd3b29e 100644 --- a/host/host_windows.go +++ b/host/host_windows.go @@ -14,8 +14,8 @@ import ( "time" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/process" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/process" "github.com/yusufpapurcu/wmi" "golang.org/x/sys/windows" ) @@ -65,7 +65,7 @@ type msAcpi_ThermalZoneTemperature struct { } func HostIDWithContext(ctx context.Context) (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/cloudsoda/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/internal/common/common.go b/internal/common/common.go index 5e25e507b..a7297ee30 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -25,7 +25,7 @@ import ( "strings" "time" - "github.com/shirou/gopsutil/v3/common" + "github.com/cloudsoda/gopsutil/v3/common" ) var ( diff --git a/internal/common/common_test.go b/internal/common/common_test.go index 424ea26ab..59e009fb6 100644 --- a/internal/common/common_test.go +++ b/internal/common/common_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/shirou/gopsutil/v3/common" + "github.com/cloudsoda/gopsutil/v3/common" ) func TestReadlines(t *testing.T) { diff --git a/internal/common/common_windows.go b/internal/common/common_windows.go index 301b2315b..0e5e4ebad 100644 --- a/internal/common/common_windows.go +++ b/internal/common/common_windows.go @@ -302,3 +302,215 @@ func NtQuerySystemInformation( uintptr(unsafe.Pointer(ReturnLength))) return NtStatus(r0) } + +// represents a win32 thread status +// see for possible values +type THREAD_STATE uint32 + +const ( + StateInitialized THREAD_STATE = iota + StateReady + StateRunning + StateStandby + StateTerminated + StateWait + StateTransition + StateUnknown +) + +func (s THREAD_STATE) String() string { + switch s { + case StateInitialized: + return "StateInitialized" + case StateReady: + return "StateReady" + case StateRunning: + return "StateRunning" + case StateStandby: + return "StateStandby" + case StateTerminated: + return "StateTerminated" + case StateWait: + return "StateWait" + case StateTransition: + return "StateTransition" + case StateUnknown: + return "StateUnknown" + default: + return "" + } +} + +// "BUSY" thread means a thread that is either running, transitioning to run or on a state that demans resources +// see https://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html +func (s THREAD_STATE) Busy() bool { + switch s { + case StateReady, StateRunning, StateStandby, StateTransition: + return true + default: + return false + } +} + +// SYSTEM_THREAD_INFORMATION contains thread information as it is returned by NtQuerySystemInformation() API call +// look for its structure & documentation at: +// https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation +type SYSTEM_THREAD_INFORMATION struct { + Reserved1 [3]int64 + Reserved2 uint32 + StartAddress uintptr + UniqueProcess windows.Handle + UniqueThread windows.Handle + Priority int32 + BasePriority int32 + Reserved3 uint32 + ThreadState THREAD_STATE + WaitReason uint32 +} + +// SYSTEM_PROCESS_INFORMATION is a convenience struct to have first thread address at hand +// for this technique to access to heterogeneous data, see: +// https://justen.codes/breaking-all-the-rules-using-go-to-call-windows-api-2cbfd8c79724 +type SYSTEM_PROCESS_INFORMATION struct { + windows.SYSTEM_PROCESS_INFORMATION + ThreadsTable [1]SYSTEM_THREAD_INFORMATION +} + +// Stats are the stats this package offers +type Stats struct { + ProcessCount uint32 + ThreadCount uint32 + ThreadsByStatus map[THREAD_STATE]uint32 + Load uint32 // number of threads that contribute to system load, see https://www.brendangregg.com/blog/2017-08-08/linux-load-averages.html +} + +func EmptyStats() *Stats { + return &Stats{ + ThreadsByStatus: make(map[THREAD_STATE]uint32), + } +} + +// AddProc increments process count and returns itself. +func (s *Stats) AddProc() *Stats { + s.ProcessCount += 1 + return s +} + +// AddThread increments thread count, also updates ThreadsByStatus based on the status, +// finally if the state represents a busy thread, it increments the load. +// returns the current stats structure pointer. +func (s *Stats) AddThread(state THREAD_STATE) *Stats { + s.ThreadCount += 1 + s.ThreadsByStatus[state] += 1 + + if state.Busy() { + s.Load += 1 + } + + return s +} + +// SystemProcessInformationWalk is a helper structure to walk through the raw bytes +// that NtQuerySystemInformation produces and get correct structures +type SystemProcessInformationWalk struct { + SizeInBytes uint32 // buffer size + Offset uint32 // current offset + Buffer []byte // buffer with the data +} + +// Process returns the process under current offset +func (w *SystemProcessInformationWalk) Process() *SYSTEM_PROCESS_INFORMATION { + return (*SYSTEM_PROCESS_INFORMATION)(unsafe.Pointer(&w.Buffer[w.Offset])) +} + +// Next moves offset to the next process structure +// it returns true if there are still more PENDING processess to iterate +// it returns false if there are no more PENDING processess to iterate +// calling Next() when there are no more processes, has no effect +func (w *SystemProcessInformationWalk) Next() bool { + proc := w.Process() + + if proc.NextEntryOffset == 0 || proc.NextEntryOffset+w.Offset > w.SizeInBytes { + return false // reached the end + } + + w.Offset += proc.NextEntryOffset + + return true +} + +// Stats calculate stats for all processes and their threads +func (w *SystemProcessInformationWalk) Stats() *Stats { + stats := EmptyStats() + + for { + proc := w.Process() + + stats.AddProc() + + WalkThreads(proc, func(t SYSTEM_THREAD_INFORMATION) { + stats.AddThread(t.ThreadState) + }) + + if ok := w.Next(); !ok { + break + } + } + + return stats +} + +// WalkThreads() iterates over all threads of current process and applies given function +func WalkThreads(proc *SYSTEM_PROCESS_INFORMATION, fn func(t SYSTEM_THREAD_INFORMATION)) { + for i := 0; i < int(proc.NumberOfThreads); i++ { + thread := *(*SYSTEM_THREAD_INFORMATION)(unsafe.Pointer( + uintptr(unsafe.Pointer(&proc.ThreadsTable[0])) + + uintptr(i)*unsafe.Sizeof(proc.ThreadsTable[0]), + )) + + fn(thread) + } +} + +// GetSystemProcessInformation retrieves information of all procecess and threads +// see: https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation +// look for SystemProcessInformation and related structures SYSTEM_PROCESS_INFORMATION and SYSTEM_THREAD_INFORMATION +// the returned structure has methods to walk through the structure +func GetSystemProcessInformation() (*SystemProcessInformationWalk, error) { + var ( + oneKb uint32 = 1024 + allocKb uint32 = 1 + buffer []byte + usedBytes uint32 + ) + + // iterating instead of calling common.CallWithExpandingBuffer hangs forever + for { + var allocBytes uint32 = allocKb * oneKb + buffer = make([]byte, allocBytes) + + st := NtQuerySystemInformation( + windows.SystemProcessInformation, + &buffer[0], + allocBytes, + &usedBytes, + ) + + if st == NtStatus(windows.STATUS_INFO_LENGTH_MISMATCH) { + allocKb *= 2 + continue + } + + if st.IsError() { + return nil, st.Error() + } + + break + } + + return &SystemProcessInformationWalk{ + SizeInBytes: usedBytes, + Offset: 0, + Buffer: buffer, + }, nil +} diff --git a/internal/common/sleep_test.go b/internal/common/sleep_test.go index aadc7667c..434b3652e 100644 --- a/internal/common/sleep_test.go +++ b/internal/common/sleep_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func TestSleep(test *testing.T) { diff --git a/load/load.go b/load/load.go index 0da50904e..d3cc9947e 100644 --- a/load/load.go +++ b/load/load.go @@ -3,7 +3,7 @@ package load import ( "encoding/json" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/load/load_aix_nocgo.go b/load/load_aix_nocgo.go index 25d50ac18..68734482e 100644 --- a/load/load_aix_nocgo.go +++ b/load/load_aix_nocgo.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var separator = regexp.MustCompile(`,?\s+`) diff --git a/load/load_fallback.go b/load/load_fallback.go index 3e41fd1ea..5fd4b29ed 100644 --- a/load/load_fallback.go +++ b/load/load_fallback.go @@ -6,7 +6,7 @@ package load import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_linux.go b/load/load_linux.go index 06bceeb84..7458d9457 100644 --- a/load/load_linux.go +++ b/load/load_linux.go @@ -10,7 +10,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func Avg() (*AvgStat, error) { diff --git a/load/load_test.go b/load/load_test.go index 1790fa559..bab600307 100644 --- a/load/load_test.go +++ b/load/load_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t testing.TB, err error) { diff --git a/load/load_windows.go b/load/load_windows.go index 5241dfaab..d128c2af3 100644 --- a/load/load_windows.go +++ b/load/load_windows.go @@ -5,11 +5,12 @@ package load import ( "context" + "log" "math" "sync" "time" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var ( @@ -34,15 +35,17 @@ func loadAvgGoroutine(ctx context.Context) { currentLoad float64 ) - counter, err := common.ProcessorQueueLengthCounter() - if err != nil || counter == nil { - return - } - tick := time.NewTicker(samplingFrequency).C f := func() { - currentLoad, err = counter.GetValue() + // calling this because common.ProcessorQueueLengthCounter() returns zero values all time + w, err := common.GetSystemProcessInformation() + if err != nil { + log.Printf("gopsutil: unexpected GetSystemProcessInformation error, please file an issue on github: %v", err) + } else { + currentLoad = float64(w.Stats().Load) + } + loadAvgMutex.Lock() loadErr = err loadAvg1M = loadAvg1M*loadAvgFactor1M + currentLoad*(1-loadAvgFactor1M) diff --git a/mem/mem.go b/mem/mem.go index edaf268bb..f20b97045 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -3,7 +3,7 @@ package mem import ( "encoding/json" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/mem/mem_aix_nocgo.go b/mem/mem_aix_nocgo.go index cc6a76d2f..fabd2bef4 100644 --- a/mem/mem_aix_nocgo.go +++ b/mem/mem_aix_nocgo.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index a05a0faba..226befacb 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -10,7 +10,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func getHwMemsize() (uint64, error) { diff --git a/mem/mem_fallback.go b/mem/mem_fallback.go index 697fd8709..e685c2411 100644 --- a/mem/mem_fallback.go +++ b/mem/mem_fallback.go @@ -6,7 +6,7 @@ package mem import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func VirtualMemory() (*VirtualMemoryStat, error) { diff --git a/mem/mem_freebsd.go b/mem/mem_freebsd.go index 9a56785b3..59eef0017 100644 --- a/mem/mem_freebsd.go +++ b/mem/mem_freebsd.go @@ -8,7 +8,7 @@ import ( "errors" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_linux.go b/mem/mem_linux.go index 214a91e47..f1abbe1d5 100644 --- a/mem/mem_linux.go +++ b/mem/mem_linux.go @@ -16,7 +16,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) type VirtualMemoryExStat struct { diff --git a/mem/mem_openbsd.go b/mem/mem_openbsd.go index e37d5abe0..2b5637688 100644 --- a/mem/mem_openbsd.go +++ b/mem/mem_openbsd.go @@ -10,7 +10,7 @@ import ( "errors" "fmt" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/unix" ) diff --git a/mem/mem_plan9.go b/mem/mem_plan9.go index b5259f844..ecb5b4d9a 100644 --- a/mem/mem_plan9.go +++ b/mem/mem_plan9.go @@ -8,7 +8,7 @@ import ( "os" stats "github.com/lufia/plan9stats" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func SwapMemory() (*SwapMemoryStat, error) { diff --git a/mem/mem_solaris.go b/mem/mem_solaris.go index c911267e1..a0a2404bd 100644 --- a/mem/mem_solaris.go +++ b/mem/mem_solaris.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "github.com/tklauser/go-sysconf" ) diff --git a/mem/mem_test.go b/mem/mem_test.go index 79ddb0fc6..5ff53718e 100644 --- a/mem/mem_test.go +++ b/mem/mem_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/mem/mem_windows.go b/mem/mem_windows.go index 8c7fb1a13..107a030c0 100644 --- a/mem/mem_windows.go +++ b/mem/mem_windows.go @@ -9,7 +9,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/windows" ) diff --git a/net/net.go b/net/net.go index 0f3a62f39..8cdc78028 100644 --- a/net/net.go +++ b/net/net.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var invoke common.Invoker = common.Invoke{} diff --git a/net/net_aix.go b/net/net_aix.go index 81feaa8d7..93317dee9 100644 --- a/net/net_aix.go +++ b/net/net_aix.go @@ -11,7 +11,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_aix_nocgo.go b/net/net_aix_nocgo.go index e3fce9021..1304e4001 100644 --- a/net/net_aix_nocgo.go +++ b/net/net_aix_nocgo.go @@ -9,7 +9,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func parseNetstatI(output string) ([]IOCountersStat, error) { diff --git a/net/net_darwin.go b/net/net_darwin.go index 8a7b63744..82042fbcd 100644 --- a/net/net_darwin.go +++ b/net/net_darwin.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var ( diff --git a/net/net_fallback.go b/net/net_fallback.go index e136be1ba..cc8f5cf52 100644 --- a/net/net_fallback.go +++ b/net/net_fallback.go @@ -6,7 +6,7 @@ package net import ( "context" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_freebsd.go b/net/net_freebsd.go index bf8baf094..d91f3b0b2 100644 --- a/net/net_freebsd.go +++ b/net/net_freebsd.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func IOCounters(pernic bool) ([]IOCountersStat, error) { diff --git a/net/net_linux.go b/net/net_linux.go index 6e8ce67fb..9f1776e98 100644 --- a/net/net_linux.go +++ b/net/net_linux.go @@ -16,7 +16,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) const ( // Conntrack Column numbers @@ -782,7 +782,7 @@ func processInetWithContext(ctx context.Context, file string, kind netConnection // 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/cloudsoda/gopsutil/pull/361 contents, err := os.ReadFile(file) if err != nil { return nil, err @@ -843,7 +843,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/cloudsoda/gopsutil/pull/361 contents, err := os.ReadFile(file) if err != nil { return nil, err diff --git a/net/net_linux_test.go b/net/net_linux_test.go index eae0e71b9..153b37327 100644 --- a/net/net_linux_test.go +++ b/net/net_linux_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func TestIOCountersByFileParsing(t *testing.T) { diff --git a/net/net_openbsd.go b/net/net_openbsd.go index cf48f53e7..81087b72c 100644 --- a/net/net_openbsd.go +++ b/net/net_openbsd.go @@ -12,7 +12,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`) diff --git a/net/net_solaris.go b/net/net_solaris.go index 79d8ac30e..7cbb72f88 100644 --- a/net/net_solaris.go +++ b/net/net_solaris.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // NetIOCounters returnes network I/O statistics for every network diff --git a/net/net_test.go b/net/net_test.go index 72f4db9c5..72dbd0210 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -7,7 +7,7 @@ import ( "runtime" "testing" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func skipIfNotImplementedErr(t *testing.T, err error) { diff --git a/net/net_unix.go b/net/net_unix.go index cb846e28a..b6d5ffdc7 100644 --- a/net/net_unix.go +++ b/net/net_unix.go @@ -11,7 +11,7 @@ import ( "strings" "syscall" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) // Return a list of network connections opened. diff --git a/net/net_windows.go b/net/net_windows.go index 5d384342f..dfde43aee 100644 --- a/net/net_windows.go +++ b/net/net_windows.go @@ -11,7 +11,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/windows" ) diff --git a/process/process.go b/process/process.go index 1bb27abf8..e057bc51d 100644 --- a/process/process.go +++ b/process/process.go @@ -9,10 +9,10 @@ import ( "sync" "time" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/mem" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/mem" + "github.com/cloudsoda/gopsutil/v3/net" ) var ( diff --git a/process/process_bsd.go b/process/process_bsd.go index 263829ffa..da56e2ad6 100644 --- a/process/process_bsd.go +++ b/process/process_bsd.go @@ -8,8 +8,8 @@ import ( "context" "encoding/binary" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) type MemoryInfoExStat struct{} diff --git a/process/process_darwin.go b/process/process_darwin.go index 176661cbd..802cc1e70 100644 --- a/process/process_darwin.go +++ b/process/process_darwin.go @@ -13,8 +13,8 @@ import ( "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" ) // copied from sys/sysctl.h @@ -108,7 +108,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { } func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { - // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details + // see https://github.com/cloudsoda/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid out, err := invoke.CommandWithContext(ctx, "ps", "-o", "stat=", "-p", strconv.Itoa(int(pid))) if err != nil { diff --git a/process/process_darwin_cgo.go b/process/process_darwin_cgo.go index 858f08e7a..2fcb0acd6 100644 --- a/process/process_darwin_cgo.go +++ b/process/process_darwin_cgo.go @@ -20,7 +20,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/cpu" ) var ( diff --git a/process/process_darwin_nocgo.go b/process/process_darwin_nocgo.go index bc1d357df..622513356 100644 --- a/process/process_darwin_nocgo.go +++ b/process/process_darwin_nocgo.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) func (p *Process) CwdWithContext(ctx context.Context) (string, error) { diff --git a/process/process_fallback.go b/process/process_fallback.go index 1a5d0c4b4..a03d16d2c 100644 --- a/process/process_fallback.go +++ b/process/process_fallback.go @@ -7,9 +7,9 @@ import ( "context" "syscall" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" ) type Signal = syscall.Signal diff --git a/process/process_freebsd.go b/process/process_freebsd.go index 40b10e14f..3d2d21f41 100644 --- a/process/process_freebsd.go +++ b/process/process_freebsd.go @@ -10,9 +10,9 @@ import ( "strconv" "strings" - cpu "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - net "github.com/shirou/gopsutil/v3/net" + cpu "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + net "github.com/cloudsoda/gopsutil/v3/net" "golang.org/x/sys/unix" ) @@ -148,7 +148,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { } func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { - // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details + // see https://github.com/cloudsoda/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid out, err := invoke.CommandWithContext(ctx, "ps", "-o", "stat=", "-p", strconv.Itoa(int(pid))) if err != nil { diff --git a/process/process_linux.go b/process/process_linux.go index 557435b34..75d12b565 100644 --- a/process/process_linux.go +++ b/process/process_linux.go @@ -18,9 +18,9 @@ import ( "github.com/tklauser/go-sysconf" "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" ) var pageSize = uint64(os.Getpagesize()) @@ -132,7 +132,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { } func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { - // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details + // see https://github.com/cloudsoda/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid statPath := common.HostProcWithContext(ctx, strconv.Itoa(int(pid)), "stat") contents, err := os.ReadFile(statPath) diff --git a/process/process_openbsd.go b/process/process_openbsd.go index a58c5eb11..9d337e0a4 100644 --- a/process/process_openbsd.go +++ b/process/process_openbsd.go @@ -14,10 +14,10 @@ import ( "strings" "unsafe" - cpu "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - mem "github.com/shirou/gopsutil/v3/mem" - net "github.com/shirou/gopsutil/v3/net" + cpu "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + mem "github.com/cloudsoda/gopsutil/v3/mem" + net "github.com/cloudsoda/gopsutil/v3/net" "golang.org/x/sys/unix" ) @@ -162,7 +162,7 @@ func (p *Process) StatusWithContext(ctx context.Context) ([]string, error) { } func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) { - // see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details + // see https://github.com/cloudsoda/gopsutil/issues/596#issuecomment-432707831 for implementation details pid := p.Pid out, err := invoke.CommandWithContext(ctx, "ps", "-o", "stat=", "-p", strconv.Itoa(int(pid))) if err != nil { diff --git a/process/process_plan9.go b/process/process_plan9.go index bc4bc062a..0039ee5a6 100644 --- a/process/process_plan9.go +++ b/process/process_plan9.go @@ -7,9 +7,9 @@ import ( "context" "syscall" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" ) type Signal = syscall.Note diff --git a/process/process_posix.go b/process/process_posix.go index a01f9ecfc..fccfa84a7 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -16,7 +16,7 @@ import ( "golang.org/x/sys/unix" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) type Signal = syscall.Signal diff --git a/process/process_solaris.go b/process/process_solaris.go index dd4bd4760..2f1618f0a 100644 --- a/process/process_solaris.go +++ b/process/process_solaris.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" ) type MemoryMapsStat struct { diff --git a/process/process_test.go b/process/process_test.go index 877992b25..0470c5445 100644 --- a/process/process_test.go +++ b/process/process_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" ) var mu sync.Mutex @@ -227,7 +227,7 @@ func Test_Process_NumCtx(t *testing.T) { func Test_Process_Nice(t *testing.T) { p := testGetProcess() - // https://github.com/shirou/gopsutil/issues/1532 + // https://github.com/cloudsoda/gopsutil/issues/1532 if os.Getenv("CI") == "true" && runtime.GOOS == "darwin" { t.Skip("Skip CI") } diff --git a/process/process_windows.go b/process/process_windows.go index f2053d985..e31bee450 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -18,9 +18,9 @@ import ( "unicode/utf16" "unsafe" - "github.com/shirou/gopsutil/v3/cpu" - "github.com/shirou/gopsutil/v3/internal/common" - "github.com/shirou/gopsutil/v3/net" + "github.com/cloudsoda/gopsutil/v3/cpu" + "github.com/cloudsoda/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/net" "golang.org/x/sys/windows" ) diff --git a/process/process_windows_32bit.go b/process/process_windows_32bit.go index db4d45334..424900b7c 100644 --- a/process/process_windows_32bit.go +++ b/process/process_windows_32bit.go @@ -8,7 +8,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/windows" ) diff --git a/process/process_windows_64bit.go b/process/process_windows_64bit.go index 74c6212cf..99ad98975 100644 --- a/process/process_windows_64bit.go +++ b/process/process_windows_64bit.go @@ -7,7 +7,7 @@ import ( "syscall" "unsafe" - "github.com/shirou/gopsutil/v3/internal/common" + "github.com/cloudsoda/gopsutil/v3/internal/common" "golang.org/x/sys/windows" )