mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
fix(deps): update module github.com/shirou/gopsutil/v4 to v4.25.10
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
85
vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go
generated
vendored
85
vendor/github.com/shirou/gopsutil/v4/cpu/cpu_windows.go
generated
vendored
@@ -8,12 +8,14 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/bits"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/internal/common"
|
||||
)
|
||||
@@ -75,6 +77,8 @@ const (
|
||||
smbiosEndOfTable = 127 // Minimum length for processor structure
|
||||
smbiosTypeProcessor = 4 // SMBIOS Type 4: Processor Information
|
||||
smbiosProcessorMinLength = 0x18 // Minimum length for processor structure
|
||||
|
||||
centralProcessorRegistryKey = `HARDWARE\DESCRIPTION\System\CentralProcessor`
|
||||
)
|
||||
|
||||
type relationship uint32
|
||||
@@ -179,61 +183,27 @@ func getProcessorPowerInformation(ctx context.Context) ([]processorPowerInformat
|
||||
|
||||
func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
|
||||
var ret []InfoStat
|
||||
var dst []win32_Processor
|
||||
q := wmi.CreateQuery(&dst, "")
|
||||
if err := common.WMIQueryWithContext(ctx, q, &dst); err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
var procID string
|
||||
for i, l := range dst {
|
||||
procID = ""
|
||||
if l.ProcessorID != nil {
|
||||
procID = *l.ProcessorID
|
||||
}
|
||||
|
||||
cpu := InfoStat{
|
||||
CPU: int32(i),
|
||||
Family: strconv.FormatUint(uint64(l.Family), 10),
|
||||
VendorID: l.Manufacturer,
|
||||
ModelName: l.Name,
|
||||
Cores: int32(l.NumberOfLogicalProcessors), // TO BE REMOVED, set by getSystemLogicalProcessorInformationEx
|
||||
PhysicalID: procID,
|
||||
Mhz: float64(l.MaxClockSpeed),
|
||||
Flags: []string{},
|
||||
}
|
||||
ret = append(ret, cpu)
|
||||
}
|
||||
|
||||
processorPackages, err := getSystemLogicalProcessorInformationEx(relationProcessorPackage)
|
||||
if err != nil {
|
||||
// return an error whem wmi will be removed
|
||||
// return ret, fmt.Errorf("failed to get processor package information: %w", err)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
if len(processorPackages) != len(ret) {
|
||||
// this should never happen, but it's kept for safety until wmi is removed
|
||||
return ret, nil
|
||||
return ret, fmt.Errorf("failed to get processor package information: %w", err)
|
||||
}
|
||||
|
||||
ppis, powerInformationErr := getProcessorPowerInformation(ctx)
|
||||
if powerInformationErr != nil {
|
||||
// return an error whem wmi will be removed
|
||||
// return ret, fmt.Errorf("failed to get processor power information: %w", err)
|
||||
return ret, nil
|
||||
return ret, fmt.Errorf("failed to get processor power information: %w", err)
|
||||
}
|
||||
|
||||
family, processorId, smBIOSErr := getSMBIOSProcessorInfo()
|
||||
if smBIOSErr != nil {
|
||||
// return an error whem wmi will be removed
|
||||
// return ret, smBIOSErr
|
||||
return ret, nil
|
||||
return ret, smBIOSErr
|
||||
}
|
||||
|
||||
for i, pkg := range processorPackages {
|
||||
logicalCount := 0
|
||||
maxMhz := 0
|
||||
model := ""
|
||||
vendorId := ""
|
||||
// iterate over each set bit in the package affinity mask
|
||||
for _, ga := range pkg.processor.groupMask {
|
||||
g := int(ga.group)
|
||||
forEachSetBit64(uint64(ga.mask), func(bit int) {
|
||||
@@ -246,12 +216,26 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
|
||||
maxMhz = m
|
||||
}
|
||||
}
|
||||
|
||||
registryKeyPath := filepath.Join(centralProcessorRegistryKey, strconv.Itoa(globalLpl))
|
||||
key, err := registry.OpenKey(registry.LOCAL_MACHINE, registryKeyPath, registry.QUERY_VALUE|registry.READ)
|
||||
if err == nil {
|
||||
model = getRegistryStringValueIfUnset(key, "ProcessorNameString", model)
|
||||
vendorId = getRegistryStringValueIfUnset(key, "VendorIdentifier", vendorId)
|
||||
_ = key.Close()
|
||||
}
|
||||
})
|
||||
}
|
||||
ret[i].Mhz = float64(maxMhz)
|
||||
ret[i].Cores = int32(logicalCount)
|
||||
ret[i].Family = strconv.FormatUint(uint64(family), 10)
|
||||
ret[i].PhysicalID = processorId
|
||||
ret = append(ret, InfoStat{
|
||||
CPU: int32(i),
|
||||
Family: strconv.FormatUint(uint64(family), 10),
|
||||
VendorID: vendorId,
|
||||
ModelName: model,
|
||||
Cores: int32(logicalCount),
|
||||
PhysicalID: processorId,
|
||||
Mhz: float64(maxMhz),
|
||||
Flags: []string{},
|
||||
})
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
@@ -461,6 +445,17 @@ func getPhysicalCoreCount() (int, error) {
|
||||
return len(infos), err
|
||||
}
|
||||
|
||||
func getRegistryStringValueIfUnset(key registry.Key, keyName, value string) string {
|
||||
if value != "" {
|
||||
return value
|
||||
}
|
||||
val, _, err := key.GetStringValue(keyName)
|
||||
if err == nil {
|
||||
return strings.TrimSpace(val)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func CountsWithContext(_ context.Context, logical bool) (int, error) {
|
||||
if logical {
|
||||
// Get logical processor count https://github.com/giampaolo/psutil/blob/d01a9eaa35a8aadf6c519839e987a49d8be2d891/psutil/_psutil_windows.c#L97
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/v4/internal/common/common.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/v4/internal/common/common.go
generated
vendored
@@ -442,7 +442,7 @@ func HostRootWithContext(ctx context.Context, combineWith ...string) string {
|
||||
}
|
||||
|
||||
// getSysctrlEnv sets LC_ALL=C in a list of env vars for use when running
|
||||
// sysctl commands (see DoSysctrl).
|
||||
// sysctl commands.
|
||||
func getSysctrlEnv(env []string) []string {
|
||||
foundLC := false
|
||||
for i, line := range env {
|
||||
|
||||
18
vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go
generated
vendored
18
vendor/github.com/shirou/gopsutil/v4/internal/common/common_darwin.go
generated
vendored
@@ -4,32 +4,14 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/ebitengine/purego"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func DoSysctrlWithContext(ctx context.Context, mib string) ([]string, error) {
|
||||
cmd := exec.CommandContext(ctx, "sysctl", "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||
miblen := uint64(len(mib))
|
||||
|
||||
|
||||
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_freebsd.go
generated
vendored
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_freebsd.go
generated
vendored
@@ -5,9 +5,6 @@ package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -28,20 +25,6 @@ func SysctlUint(mib string) (uint64, error) {
|
||||
return 0, fmt.Errorf("unexpected size: %s, %d", mib, len(buf))
|
||||
}
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
cmd := exec.Command("sysctl", "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||
mibptr := unsafe.Pointer(&mib[0])
|
||||
miblen := uint64(len(mib))
|
||||
|
||||
15
vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go
generated
vendored
15
vendor/github.com/shirou/gopsutil/v4/internal/common/common_linux.go
generated
vendored
@@ -7,7 +7,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -20,20 +19,6 @@ import (
|
||||
// cachedBootTime must be accessed via atomic.Load/StoreUint64
|
||||
var cachedBootTime uint64
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
cmd := exec.Command("sysctl", "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func NumProcs() (uint64, error) {
|
||||
return NumProcsWithContext(context.Background())
|
||||
}
|
||||
|
||||
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_netbsd.go
generated
vendored
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_netbsd.go
generated
vendored
@@ -4,28 +4,11 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
cmd := exec.Command("sysctl", "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||
mibptr := unsafe.Pointer(&mib[0])
|
||||
miblen := uint64(len(mib))
|
||||
|
||||
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_openbsd.go
generated
vendored
17
vendor/github.com/shirou/gopsutil/v4/internal/common/common_openbsd.go
generated
vendored
@@ -4,28 +4,11 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func DoSysctrl(mib string) ([]string, error) {
|
||||
cmd := exec.Command("sysctl", "-n", mib)
|
||||
cmd.Env = getSysctrlEnv(os.Environ())
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
}
|
||||
v := strings.Replace(string(out), "{ ", "", 1)
|
||||
v = strings.Replace(string(v), " }", "", 1)
|
||||
values := strings.Fields(string(v))
|
||||
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func CallSyscall(mib []int32) ([]byte, uint64, error) {
|
||||
mibptr := unsafe.Pointer(&mib[0])
|
||||
miblen := uint64(len(mib))
|
||||
|
||||
9
vendor/github.com/shirou/gopsutil/v4/internal/common/warnings.go
generated
vendored
9
vendor/github.com/shirou/gopsutil/v4/internal/common/warnings.go
generated
vendored
@@ -1,7 +1,10 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
package common
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
maxWarnings = 100 // An arbitrary limit to avoid excessive memory usage, it has no sense to store hundreds of errors
|
||||
@@ -33,9 +36,11 @@ func (w *Warnings) Reference() error {
|
||||
func (w *Warnings) Error() string {
|
||||
if w.Verbose {
|
||||
str := ""
|
||||
var sb strings.Builder
|
||||
for i, e := range w.List {
|
||||
str += fmt.Sprintf("\tError %d: %s\n", i, e.Error())
|
||||
sb.WriteString(fmt.Sprintf("\tError %d: %s\n", i, e.Error()))
|
||||
}
|
||||
str += sb.String()
|
||||
if w.tooManyErrors {
|
||||
str += fmt.Sprintf("\t%s\n", tooManyErrorsMessage)
|
||||
}
|
||||
|
||||
13
vendor/github.com/shirou/gopsutil/v4/net/net_linux.go
generated
vendored
13
vendor/github.com/shirou/gopsutil/v4/net/net_linux.go
generated
vendored
@@ -50,26 +50,25 @@ func IOCountersByFileWithContext(_ context.Context, pernic bool, filename string
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parts := make([]string, 2)
|
||||
|
||||
statlen := len(lines) - 1
|
||||
|
||||
ret := make([]IOCountersStat, 0, statlen)
|
||||
|
||||
for _, line := range lines[2:] {
|
||||
// Split interface name and stats data at the last ":"
|
||||
separatorPos := strings.LastIndex(line, ":")
|
||||
if separatorPos == -1 {
|
||||
continue
|
||||
}
|
||||
parts[0] = line[0:separatorPos]
|
||||
parts[1] = line[separatorPos+1:]
|
||||
interfacePart := line[0:separatorPos]
|
||||
statsPart := line[separatorPos+1:]
|
||||
|
||||
interfaceName := strings.TrimSpace(parts[0])
|
||||
interfaceName := strings.TrimSpace(interfacePart)
|
||||
if interfaceName == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
fields := strings.Fields(strings.TrimSpace(parts[1]))
|
||||
fields := strings.Fields(strings.TrimSpace(statsPart))
|
||||
bytesRecv, err := strconv.ParseUint(fields[0], 10, 64)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
@@ -610,7 +609,7 @@ func getProcInodesAllWithContext(ctx context.Context, root string, maxConn int)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// decodeAddress decode addresse represents addr in proc/net/*
|
||||
// decodeAddress decode address represents addr in proc/net/*
|
||||
// ex:
|
||||
// "0500000A:0016" -> "10.0.0.5", 22
|
||||
// "0085002452100113070057A13F025401:0035" -> "2400:8500:1301:1052:a157:7:154:23f", 53
|
||||
|
||||
2
vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
generated
vendored
2
vendor/github.com/shirou/gopsutil/v4/process/process_darwin.go
generated
vendored
@@ -237,7 +237,7 @@ func (p *Process) getKProc() (*unix.KinfoProc, error) {
|
||||
|
||||
// call ps command.
|
||||
// Return value deletes Header line(you must not input wrong arg).
|
||||
// And splited by Space. Caller have responsibility to manage.
|
||||
// And split by Space. Caller have responsibility to manage.
|
||||
// If passed arg pid is 0, get information from all process.
|
||||
func callPsWithContext(ctx context.Context, arg string, pid int32, threadOption, nameOption bool) ([][]string, error) {
|
||||
var cmd []string
|
||||
|
||||
Reference in New Issue
Block a user