mirror of https://github.com/containers/podman.git
fix(deps): update module github.com/shirou/gopsutil/v4 to v4.25.5
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
parent
746cbf12c9
commit
04a1a39a69
4
go.mod
4
go.mod
|
@ -60,7 +60,7 @@ require (
|
||||||
github.com/opencontainers/selinux v1.12.0
|
github.com/opencontainers/selinux v1.12.0
|
||||||
github.com/openshift/imagebuilder v1.2.16-0.20250224193648-e87e4e105fd8
|
github.com/openshift/imagebuilder v1.2.16-0.20250224193648-e87e4e105fd8
|
||||||
github.com/rootless-containers/rootlesskit/v2 v2.3.5
|
github.com/rootless-containers/rootlesskit/v2 v2.3.5
|
||||||
github.com/shirou/gopsutil/v4 v4.25.4
|
github.com/shirou/gopsutil/v4 v4.25.5
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/cobra v1.9.1
|
github.com/spf13/cobra v1.9.1
|
||||||
github.com/spf13/pflag v1.0.6
|
github.com/spf13/pflag v1.0.6
|
||||||
|
@ -108,7 +108,7 @@ require (
|
||||||
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
|
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
|
||||||
github.com/distribution/reference v0.6.0 // indirect
|
github.com/distribution/reference v0.6.0 // indirect
|
||||||
github.com/docker/docker-credential-helpers v0.9.3 // indirect
|
github.com/docker/docker-credential-helpers v0.9.3 // indirect
|
||||||
github.com/ebitengine/purego v0.8.3 // indirect
|
github.com/ebitengine/purego v0.8.4 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
github.com/fsouza/go-dockerclient v1.12.0 // indirect
|
github.com/fsouza/go-dockerclient v1.12.0 // indirect
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -135,8 +135,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4
|
||||||
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/ebitengine/purego v0.8.3 h1:K+0AjQp63JEZTEMZiwsI9g0+hAMNohwUOtY0RPGexmc=
|
github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw=
|
||||||
github.com/ebitengine/purego v0.8.3/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
@ -422,8 +422,8 @@ github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c
|
||||||
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
|
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
|
||||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||||
github.com/shirou/gopsutil/v4 v4.25.4 h1:cdtFO363VEOOFrUCjZRh4XVJkb548lyF0q0uTeMqYPw=
|
github.com/shirou/gopsutil/v4 v4.25.5 h1:rtd9piuSMGeU8g1RMXjZs9y9luK5BwtnG7dZaQUJAsc=
|
||||||
github.com/shirou/gopsutil/v4 v4.25.4/go.mod h1:xbuxyoZj+UsgnZrENu3lQivsngRR5BdjbJwf2fv4szA=
|
github.com/shirou/gopsutil/v4 v4.25.5/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c=
|
||||||
github.com/sigstore/fulcio v1.6.6 h1:XaMYX6TNT+8n7Npe8D94nyZ7/ERjEsNGFC+REdi/wzw=
|
github.com/sigstore/fulcio v1.6.6 h1:XaMYX6TNT+8n7Npe8D94nyZ7/ERjEsNGFC+REdi/wzw=
|
||||||
github.com/sigstore/fulcio v1.6.6/go.mod h1:BhQ22lwaebDgIxVBEYOOqLRcN5+xOV+C9bh/GUXRhOk=
|
github.com/sigstore/fulcio v1.6.6/go.mod h1:BhQ22lwaebDgIxVBEYOOqLRcN5+xOV+C9bh/GUXRhOk=
|
||||||
github.com/sigstore/protobuf-specs v0.4.1 h1:5SsMqZbdkcO/DNHudaxuCUEjj6x29tS2Xby1BxGU7Zc=
|
github.com/sigstore/protobuf-specs v0.4.1 h1:5SsMqZbdkcO/DNHudaxuCUEjj6x29tS2Xby1BxGU7Zc=
|
||||||
|
|
|
@ -19,6 +19,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func x_cgo_notify_runtime_init_done() {
|
func x_cgo_notify_runtime_init_done() {
|
||||||
pthread_mutex_lock(&runtime_init_mu)
|
pthread_mutex_lock(&runtime_init_mu)
|
||||||
runtime_init_done = 1
|
runtime_init_done = 1
|
||||||
|
@ -28,6 +29,8 @@ func x_cgo_notify_runtime_init_done() {
|
||||||
|
|
||||||
// Store the g into a thread-specific value associated with the pthread key pthread_g.
|
// Store the g into a thread-specific value associated with the pthread key pthread_g.
|
||||||
// And pthread_key_destructor will dropm when the thread is exiting.
|
// And pthread_key_destructor will dropm when the thread is exiting.
|
||||||
|
//
|
||||||
|
//go:norace
|
||||||
func x_cgo_bindm(g unsafe.Pointer) {
|
func x_cgo_bindm(g unsafe.Pointer) {
|
||||||
// We assume this will always succeed, otherwise, there might be extra M leaking,
|
// We assume this will always succeed, otherwise, there might be extra M leaking,
|
||||||
// when a C thread exits after a cgo call.
|
// when a C thread exits after a cgo call.
|
||||||
|
|
|
@ -19,6 +19,7 @@ func setg_trampoline(setg uintptr, G uintptr)
|
||||||
func call5(fn, a1, a2, a3, a4, a5 uintptr) uintptr
|
func call5(fn, a1, a2, a3, a4, a5 uintptr) uintptr
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func malloc(size uintptr) unsafe.Pointer {
|
func malloc(size uintptr) unsafe.Pointer {
|
||||||
ret := call5(mallocABI0, uintptr(size), 0, 0, 0, 0)
|
ret := call5(mallocABI0, uintptr(size), 0, 0, 0, 0)
|
||||||
// this indirection is to avoid go vet complaining about possible misuse of unsafe.Pointer
|
// this indirection is to avoid go vet complaining about possible misuse of unsafe.Pointer
|
||||||
|
@ -26,96 +27,115 @@ func malloc(size uintptr) unsafe.Pointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func free(ptr unsafe.Pointer) {
|
func free(ptr unsafe.Pointer) {
|
||||||
call5(freeABI0, uintptr(ptr), 0, 0, 0, 0)
|
call5(freeABI0, uintptr(ptr), 0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func setenv(name *byte, value *byte, overwrite int32) int32 {
|
func setenv(name *byte, value *byte, overwrite int32) int32 {
|
||||||
return int32(call5(setenvABI0, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), uintptr(overwrite), 0, 0))
|
return int32(call5(setenvABI0, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), uintptr(overwrite), 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func unsetenv(name *byte) int32 {
|
func unsetenv(name *byte) int32 {
|
||||||
return int32(call5(unsetenvABI0, uintptr(unsafe.Pointer(name)), 0, 0, 0, 0))
|
return int32(call5(unsetenvABI0, uintptr(unsafe.Pointer(name)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func sigfillset(set *sigset_t) int32 {
|
func sigfillset(set *sigset_t) int32 {
|
||||||
return int32(call5(sigfillsetABI0, uintptr(unsafe.Pointer(set)), 0, 0, 0, 0))
|
return int32(call5(sigfillsetABI0, uintptr(unsafe.Pointer(set)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func nanosleep(ts *syscall.Timespec, rem *syscall.Timespec) int32 {
|
func nanosleep(ts *syscall.Timespec, rem *syscall.Timespec) int32 {
|
||||||
return int32(call5(nanosleepABI0, uintptr(unsafe.Pointer(ts)), uintptr(unsafe.Pointer(rem)), 0, 0, 0))
|
return int32(call5(nanosleepABI0, uintptr(unsafe.Pointer(ts)), uintptr(unsafe.Pointer(rem)), 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func abort() {
|
func abort() {
|
||||||
call5(abortABI0, 0, 0, 0, 0, 0)
|
call5(abortABI0, 0, 0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_attr_init(attr *pthread_attr_t) int32 {
|
func pthread_attr_init(attr *pthread_attr_t) int32 {
|
||||||
return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
|
return int32(call5(pthread_attr_initABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_create(thread *pthread_t, attr *pthread_attr_t, start unsafe.Pointer, arg unsafe.Pointer) int32 {
|
func pthread_create(thread *pthread_t, attr *pthread_attr_t, start unsafe.Pointer, arg unsafe.Pointer) int32 {
|
||||||
return int32(call5(pthread_createABI0, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(start), uintptr(arg), 0))
|
return int32(call5(pthread_createABI0, uintptr(unsafe.Pointer(thread)), uintptr(unsafe.Pointer(attr)), uintptr(start), uintptr(arg), 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_detach(thread pthread_t) int32 {
|
func pthread_detach(thread pthread_t) int32 {
|
||||||
return int32(call5(pthread_detachABI0, uintptr(thread), 0, 0, 0, 0))
|
return int32(call5(pthread_detachABI0, uintptr(thread), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_sigmask(how sighow, ign *sigset_t, oset *sigset_t) int32 {
|
func pthread_sigmask(how sighow, ign *sigset_t, oset *sigset_t) int32 {
|
||||||
return int32(call5(pthread_sigmaskABI0, uintptr(how), uintptr(unsafe.Pointer(ign)), uintptr(unsafe.Pointer(oset)), 0, 0))
|
return int32(call5(pthread_sigmaskABI0, uintptr(how), uintptr(unsafe.Pointer(ign)), uintptr(unsafe.Pointer(oset)), 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_self() pthread_t {
|
func pthread_self() pthread_t {
|
||||||
return pthread_t(call5(pthread_selfABI0, 0, 0, 0, 0, 0))
|
return pthread_t(call5(pthread_selfABI0, 0, 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_get_stacksize_np(thread pthread_t) size_t {
|
func pthread_get_stacksize_np(thread pthread_t) size_t {
|
||||||
return size_t(call5(pthread_get_stacksize_npABI0, uintptr(thread), 0, 0, 0, 0))
|
return size_t(call5(pthread_get_stacksize_npABI0, uintptr(thread), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_attr_getstacksize(attr *pthread_attr_t, stacksize *size_t) int32 {
|
func pthread_attr_getstacksize(attr *pthread_attr_t, stacksize *size_t) int32 {
|
||||||
return int32(call5(pthread_attr_getstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(unsafe.Pointer(stacksize)), 0, 0, 0))
|
return int32(call5(pthread_attr_getstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(unsafe.Pointer(stacksize)), 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_attr_setstacksize(attr *pthread_attr_t, size size_t) int32 {
|
func pthread_attr_setstacksize(attr *pthread_attr_t, size size_t) int32 {
|
||||||
return int32(call5(pthread_attr_setstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(size), 0, 0, 0))
|
return int32(call5(pthread_attr_setstacksizeABI0, uintptr(unsafe.Pointer(attr)), uintptr(size), 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_attr_destroy(attr *pthread_attr_t) int32 {
|
func pthread_attr_destroy(attr *pthread_attr_t) int32 {
|
||||||
return int32(call5(pthread_attr_destroyABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
|
return int32(call5(pthread_attr_destroyABI0, uintptr(unsafe.Pointer(attr)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_mutex_lock(mutex *pthread_mutex_t) int32 {
|
func pthread_mutex_lock(mutex *pthread_mutex_t) int32 {
|
||||||
return int32(call5(pthread_mutex_lockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0))
|
return int32(call5(pthread_mutex_lockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_mutex_unlock(mutex *pthread_mutex_t) int32 {
|
func pthread_mutex_unlock(mutex *pthread_mutex_t) int32 {
|
||||||
return int32(call5(pthread_mutex_unlockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0))
|
return int32(call5(pthread_mutex_unlockABI0, uintptr(unsafe.Pointer(mutex)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_cond_broadcast(cond *pthread_cond_t) int32 {
|
func pthread_cond_broadcast(cond *pthread_cond_t) int32 {
|
||||||
return int32(call5(pthread_cond_broadcastABI0, uintptr(unsafe.Pointer(cond)), 0, 0, 0, 0))
|
return int32(call5(pthread_cond_broadcastABI0, uintptr(unsafe.Pointer(cond)), 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
|
//go:norace
|
||||||
func pthread_setspecific(key pthread_key_t, value unsafe.Pointer) int32 {
|
func pthread_setspecific(key pthread_key_t, value unsafe.Pointer) int32 {
|
||||||
return int32(call5(pthread_setspecificABI0, uintptr(key), uintptr(value), 0, 0, 0))
|
return int32(call5(pthread_setspecificABI0, uintptr(key), uintptr(value), 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ func getFrequency() (float64, error) {
|
||||||
var pCoreHz uint32
|
var pCoreHz uint32
|
||||||
for {
|
for {
|
||||||
service := ioIteratorNext(iterator)
|
service := ioIteratorNext(iterator)
|
||||||
if !(service > 0) {
|
if service <= 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err erro
|
||||||
|
|
||||||
ncpu, err := unix.SysctlUint32("hw.ncpu")
|
ncpu, err := unix.SysctlUint32("hw.ncpu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return //nolint:nakedret //FIXME
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var i uint32
|
var i uint32
|
||||||
|
|
|
@ -75,7 +75,7 @@ func TimesWithContext(_ context.Context, percpu bool) (ret []TimesStat, err erro
|
||||||
|
|
||||||
ncpu, err := unix.SysctlUint32("hw.ncpu")
|
ncpu, err := unix.SysctlUint32("hw.ncpu")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return //nolint:nakedret //FIXME
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var i uint32
|
var i uint32
|
||||||
|
|
|
@ -159,10 +159,7 @@ func parseISAInfo(cmdOutput string) ([]string, error) {
|
||||||
return nil, errors.New("attempted to parse invalid isainfo output")
|
return nil, errors.New("attempted to parse invalid isainfo output")
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := make([]string, len(words)-4)
|
flags := words[4:]
|
||||||
for i, val := range words[4:] { //nolint:gosimple //FIXME
|
|
||||||
flags[i] = val
|
|
||||||
}
|
|
||||||
sort.Strings(flags)
|
sort.Strings(flags)
|
||||||
|
|
||||||
return flags, nil
|
return flags, nil
|
||||||
|
|
|
@ -5,6 +5,7 @@ package cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
@ -15,7 +16,10 @@ import (
|
||||||
"github.com/shirou/gopsutil/v4/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
var (
|
||||||
|
procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
||||||
|
procGetLogicalProcessorInformationEx = common.Modkernel32.NewProc("GetLogicalProcessorInformationEx")
|
||||||
|
)
|
||||||
|
|
||||||
type win32_Processor struct { //nolint:revive //FIXME
|
type win32_Processor struct { //nolint:revive //FIXME
|
||||||
Family uint16
|
Family uint16
|
||||||
|
@ -67,12 +71,14 @@ func TimesWithContext(_ context.Context, percpu bool) ([]TimesStat, error) {
|
||||||
var lpIdleTime common.FILETIME
|
var lpIdleTime common.FILETIME
|
||||||
var lpKernelTime common.FILETIME
|
var lpKernelTime common.FILETIME
|
||||||
var lpUserTime common.FILETIME
|
var lpUserTime common.FILETIME
|
||||||
r, _, _ := common.ProcGetSystemTimes.Call(
|
// GetSystemTimes returns 0 for error, in which case we check err,
|
||||||
|
// see https://pkg.go.dev/golang.org/x/sys/windows#LazyProc.Call
|
||||||
|
r, _, err := common.ProcGetSystemTimes.Call(
|
||||||
uintptr(unsafe.Pointer(&lpIdleTime)),
|
uintptr(unsafe.Pointer(&lpIdleTime)),
|
||||||
uintptr(unsafe.Pointer(&lpKernelTime)),
|
uintptr(unsafe.Pointer(&lpKernelTime)),
|
||||||
uintptr(unsafe.Pointer(&lpUserTime)))
|
uintptr(unsafe.Pointer(&lpUserTime)))
|
||||||
if r == 0 {
|
if r == 0 {
|
||||||
return ret, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
LOT := float64(0.0000001)
|
LOT := float64(0.0000001)
|
||||||
|
@ -200,13 +206,70 @@ type systemInfo struct {
|
||||||
wProcessorRevision uint16
|
wProcessorRevision uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func CountsWithContext(ctx context.Context, logical bool) (int, error) {
|
type groupAffinity struct {
|
||||||
|
mask uintptr // https://learn.microsoft.com/it-it/windows-hardware/drivers/kernel/interrupt-affinity-and-priority#about-kaffinity
|
||||||
|
group uint16
|
||||||
|
reserved [3]uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-processor_relationship
|
||||||
|
type processorRelationship struct {
|
||||||
|
flags byte
|
||||||
|
efficientClass byte
|
||||||
|
reserved [20]byte
|
||||||
|
groupCount uint16
|
||||||
|
groupMask [1]groupAffinity
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-system_logical_processor_information_ex
|
||||||
|
type systemLogicalProcessorInformationEx struct {
|
||||||
|
Relationship uint32
|
||||||
|
Size uint32
|
||||||
|
Processor processorRelationship
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPhysicalCoreCount() (int, error) {
|
||||||
|
var length uint32
|
||||||
|
const relationAll = 0xffff
|
||||||
|
const relationProcessorCore = 0x0
|
||||||
|
|
||||||
|
// First call to determine the required buffer size
|
||||||
|
_, _, err := procGetLogicalProcessorInformationEx.Call(uintptr(relationAll), 0, uintptr(unsafe.Pointer(&length)))
|
||||||
|
if err != nil && !errors.Is(err, windows.ERROR_INSUFFICIENT_BUFFER) {
|
||||||
|
return 0, fmt.Errorf("failed to get buffer size: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate the buffer
|
||||||
|
buffer := make([]byte, length)
|
||||||
|
|
||||||
|
// Second call to retrieve the processor information
|
||||||
|
_, _, err = procGetLogicalProcessorInformationEx.Call(uintptr(relationAll), uintptr(unsafe.Pointer(&buffer[0])), uintptr(unsafe.Pointer(&length)))
|
||||||
|
if err != nil && !errors.Is(err, windows.NTE_OP_OK) {
|
||||||
|
return 0, fmt.Errorf("failed to get logical processor information: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate through the buffer to count physical cores
|
||||||
|
offset := uintptr(0)
|
||||||
|
ncpus := 0
|
||||||
|
for offset < uintptr(length) {
|
||||||
|
info := (*systemLogicalProcessorInformationEx)(unsafe.Pointer(uintptr(unsafe.Pointer(&buffer[0])) + offset))
|
||||||
|
if info.Relationship == relationProcessorCore {
|
||||||
|
ncpus++
|
||||||
|
}
|
||||||
|
offset += uintptr(info.Size)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ncpus, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CountsWithContext(_ context.Context, logical bool) (int, error) {
|
||||||
if logical {
|
if logical {
|
||||||
// https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_psutil_windows.c#L97
|
// Get logical processor count https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_psutil_windows.c#L97
|
||||||
ret := windows.GetActiveProcessorCount(windows.ALL_PROCESSOR_GROUPS)
|
ret := windows.GetActiveProcessorCount(windows.ALL_PROCESSOR_GROUPS)
|
||||||
if ret != 0 {
|
if ret != 0 {
|
||||||
return int(ret), nil
|
return int(ret), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var systemInfo systemInfo
|
var systemInfo systemInfo
|
||||||
_, _, err := procGetNativeSystemInfo.Call(uintptr(unsafe.Pointer(&systemInfo)))
|
_, _, err := procGetNativeSystemInfo.Call(uintptr(unsafe.Pointer(&systemInfo)))
|
||||||
if systemInfo.dwNumberOfProcessors == 0 {
|
if systemInfo.dwNumberOfProcessors == 0 {
|
||||||
|
@ -214,16 +277,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) {
|
||||||
}
|
}
|
||||||
return int(systemInfo.dwNumberOfProcessors), nil
|
return int(systemInfo.dwNumberOfProcessors), nil
|
||||||
}
|
}
|
||||||
// physical cores https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_psutil_windows.c#L499
|
|
||||||
// for the time being, try with unreliable and slow WMI call…
|
// Get physical core count https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_psutil_windows.c#L499
|
||||||
var dst []win32_Processor
|
return getPhysicalCoreCount()
|
||||||
q := wmi.CreateQuery(&dst, "")
|
|
||||||
if err := common.WMIQueryWithContext(ctx, q, &dst); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
var count uint32
|
|
||||||
for _, d := range dst {
|
|
||||||
count += d.NumberOfCores
|
|
||||||
}
|
|
||||||
return int(count), nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,10 +393,7 @@ func GoString(cStr *byte) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
var length int
|
var length int
|
||||||
for {
|
for *(*byte)(unsafe.Add(unsafe.Pointer(cStr), uintptr(length))) != '\x00' {
|
||||||
if *(*byte)(unsafe.Add(unsafe.Pointer(cStr), uintptr(length))) == '\x00' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
length++
|
length++
|
||||||
}
|
}
|
||||||
return string(unsafe.Slice(cStr, length))
|
return string(unsafe.Slice(cStr, length))
|
||||||
|
|
|
@ -5,8 +5,6 @@ package mem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExVirtualMemory represents Windows specific information
|
// ExVirtualMemory represents Windows specific information
|
||||||
|
@ -28,16 +26,21 @@ func NewExWindows() *ExWindows {
|
||||||
func (e *ExWindows) VirtualMemory() (*ExVirtualMemory, error) {
|
func (e *ExWindows) VirtualMemory() (*ExVirtualMemory, error) {
|
||||||
var memInfo memoryStatusEx
|
var memInfo memoryStatusEx
|
||||||
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
||||||
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
// If mem == 0 since this is an error according to GlobalMemoryStatusEx documentation
|
||||||
|
// In that case, use err which is constructed from GetLastError(),
|
||||||
|
// see https://pkg.go.dev/golang.org/x/sys/windows#LazyProc.Call
|
||||||
|
mem, _, err := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
||||||
if mem == 0 {
|
if mem == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var perfInfo performanceInformation
|
var perfInfo performanceInformation
|
||||||
perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
|
perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
|
||||||
perf, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
// Analogous to above: perf == 0 is an error according to the GetPerformanceInfo documentation,
|
||||||
|
// use err in that case
|
||||||
|
perf, _, err := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
||||||
if perf == 0 {
|
if perf == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := &ExVirtualMemory{
|
ret := &ExVirtualMemory{
|
||||||
|
|
|
@ -40,9 +40,11 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
|
func VirtualMemoryWithContext(_ context.Context) (*VirtualMemoryStat, error) {
|
||||||
var memInfo memoryStatusEx
|
var memInfo memoryStatusEx
|
||||||
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
||||||
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
// GlobalMemoryStatusEx returns 0 for error, in which case we check err,
|
||||||
|
// see https://pkg.go.dev/golang.org/x/sys/windows#LazyProc.Call
|
||||||
|
mem, _, err := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
||||||
if mem == 0 {
|
if mem == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := &VirtualMemoryStat{
|
ret := &VirtualMemoryStat{
|
||||||
|
@ -93,9 +95,11 @@ func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
|
||||||
// Get total memory from performance information
|
// Get total memory from performance information
|
||||||
var perfInfo performanceInformation
|
var perfInfo performanceInformation
|
||||||
perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
|
perfInfo.cb = uint32(unsafe.Sizeof(perfInfo))
|
||||||
mem, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
// GetPerformanceInfo returns 0 for error, in which case we check err,
|
||||||
|
// see https://pkg.go.dev/golang.org/x/sys/windows#LazyProc.Call
|
||||||
|
mem, _, err := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
||||||
if mem == 0 {
|
if mem == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
totalPhys := perfInfo.physicalTotal * perfInfo.pageSize
|
totalPhys := perfInfo.physicalTotal * perfInfo.pageSize
|
||||||
totalSys := perfInfo.commitLimit * perfInfo.pageSize
|
totalSys := perfInfo.commitLimit * perfInfo.pageSize
|
||||||
|
@ -161,9 +165,11 @@ func SwapDevicesWithContext(_ context.Context) ([]*SwapDevice, error) {
|
||||||
// the following system call invokes the supplied callback function once for each page file before returning
|
// the following system call invokes the supplied callback function once for each page file before returning
|
||||||
// see https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumpagefilesw
|
// see https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumpagefilesw
|
||||||
var swapDevices []*SwapDevice
|
var swapDevices []*SwapDevice
|
||||||
result, _, _ := procEnumPageFilesW.Call(windows.NewCallback(pEnumPageFileCallbackW), uintptr(unsafe.Pointer(&swapDevices)))
|
// EnumPageFilesW returns 0 for error, in which case we check err,
|
||||||
|
// see https://pkg.go.dev/golang.org/x/sys/windows#LazyProc.Call
|
||||||
|
result, _, err := procEnumPageFilesW.Call(windows.NewCallback(pEnumPageFileCallbackW), uintptr(unsafe.Pointer(&swapDevices)))
|
||||||
if result == 0 {
|
if result == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return swapDevices, nil
|
return swapDevices, nil
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errNetstatHeader = errors.New("Can't parse header of netstat output")
|
errNetstatHeader = errors.New("can't parse header of netstat output")
|
||||||
netstatLinkRegexp = regexp.MustCompile(`^<Link#(\d+)>$`)
|
netstatLinkRegexp = regexp.MustCompile(`^<Link#(\d+)>$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,15 +29,14 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
|
||||||
)
|
)
|
||||||
|
|
||||||
if columns[0] == "Name" {
|
if columns[0] == "Name" {
|
||||||
err = errNetstatHeader
|
return nil, nil, errNetstatHeader
|
||||||
return //nolint:nakedret //FIXME
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to extract the numeric value from <Link#123>
|
// try to extract the numeric value from <Link#123>
|
||||||
if subMatch := netstatLinkRegexp.FindStringSubmatch(columns[2]); len(subMatch) == 2 {
|
if subMatch := netstatLinkRegexp.FindStringSubmatch(columns[2]); len(subMatch) == 2 {
|
||||||
numericValue, err = strconv.ParseUint(subMatch[1], 10, 64)
|
numericValue, err = strconv.ParseUint(subMatch[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return //nolint:nakedret //FIXME
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
linkIDUint := uint(numericValue)
|
linkIDUint := uint(numericValue)
|
||||||
linkID = &linkIDUint
|
linkID = &linkIDUint
|
||||||
|
@ -50,8 +49,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
|
||||||
base = 0
|
base = 0
|
||||||
}
|
}
|
||||||
if numberColumns < 11 || numberColumns > 13 {
|
if numberColumns < 11 || numberColumns > 13 {
|
||||||
err = fmt.Errorf("Line %q do have an invalid number of columns %d", line, numberColumns)
|
return nil, nil, fmt.Errorf("line %q do have an invalid number of columns %d", line, numberColumns)
|
||||||
return //nolint:nakedret //FIXME
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parsed := make([]uint64, 0, 7)
|
parsed := make([]uint64, 0, 7)
|
||||||
|
@ -74,7 +72,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
|
||||||
}
|
}
|
||||||
|
|
||||||
if numericValue, err = strconv.ParseUint(target, 10, 64); err != nil {
|
if numericValue, err = strconv.ParseUint(target, 10, 64); err != nil {
|
||||||
return //nolint:nakedret //FIXME
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
parsed = append(parsed, numericValue)
|
parsed = append(parsed, numericValue)
|
||||||
}
|
}
|
||||||
|
@ -91,7 +89,7 @@ func parseNetstatLine(line string) (stat *IOCountersStat, linkID *uint, err erro
|
||||||
if len(parsed) == 7 {
|
if len(parsed) == 7 {
|
||||||
stat.Dropout = parsed[6]
|
stat.Dropout = parsed[6]
|
||||||
}
|
}
|
||||||
return //nolint:nakedret //FIXME
|
return stat, linkID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type netstatInterface struct {
|
type netstatInterface struct {
|
||||||
|
|
|
@ -296,7 +296,7 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
|
||||||
}
|
}
|
||||||
lines := strings.Split(string(out), "\n")
|
lines := strings.Split(string(out), "\n")
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
if !(strings.HasPrefix(line, "tcp") || strings.HasPrefix(line, "udp")) {
|
if !strings.HasPrefix(line, "tcp") && !strings.HasPrefix(line, "udp") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
n, err := parseNetstatLine(line)
|
n, err := parseNetstatLine(line)
|
||||||
|
|
|
@ -594,7 +594,7 @@ func (p *Process) NumThreadsWithContext(_ context.Context) (int32, error) {
|
||||||
|
|
||||||
// if no errors and not cached already, cache ppid
|
// if no errors and not cached already, cache ppid
|
||||||
p.parent = ppid
|
p.parent = ppid
|
||||||
if 0 == p.getPpid() {
|
if p.getPpid() == 0 {
|
||||||
p.setPpid(ppid)
|
p.setPpid(ppid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,7 @@ github.com/docker/go-plugins-helpers/volume
|
||||||
# github.com/docker/go-units v0.5.0
|
# github.com/docker/go-units v0.5.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/go-units
|
github.com/docker/go-units
|
||||||
# github.com/ebitengine/purego v0.8.3
|
# github.com/ebitengine/purego v0.8.4
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
github.com/ebitengine/purego
|
github.com/ebitengine/purego
|
||||||
github.com/ebitengine/purego/internal/cgo
|
github.com/ebitengine/purego/internal/cgo
|
||||||
|
@ -897,7 +897,7 @@ github.com/secure-systems-lab/go-securesystemslib/encrypted
|
||||||
# github.com/segmentio/ksuid v1.0.4
|
# github.com/segmentio/ksuid v1.0.4
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/segmentio/ksuid
|
github.com/segmentio/ksuid
|
||||||
# github.com/shirou/gopsutil/v4 v4.25.4
|
# github.com/shirou/gopsutil/v4 v4.25.5
|
||||||
## explicit; go 1.23
|
## explicit; go 1.23
|
||||||
github.com/shirou/gopsutil/v4/common
|
github.com/shirou/gopsutil/v4/common
|
||||||
github.com/shirou/gopsutil/v4/cpu
|
github.com/shirou/gopsutil/v4/cpu
|
||||||
|
|
Loading…
Reference in New Issue