mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
Merge pull request #23843 from mikelolasagasti/gopsutil-v4
Update module github.com/shirou/gopsutil to v4
This commit is contained in:
@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
"github.com/containers/podman/v5/pkg/machine/shim"
|
"github.com/containers/podman/v5/pkg/machine/shim"
|
||||||
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
||||||
"github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v4/mem"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/containers/common/pkg/completion"
|
"github.com/containers/common/pkg/completion"
|
||||||
"github.com/containers/podman/v5/cmd/podman/registry"
|
"github.com/containers/podman/v5/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v5/pkg/fileserver"
|
"github.com/containers/podman/v5/pkg/fileserver"
|
||||||
psutil "github.com/shirou/gopsutil/v3/process"
|
psutil "github.com/shirou/gopsutil/v4/process"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
2
go.mod
2
go.mod
@ -61,7 +61,7 @@ require (
|
|||||||
github.com/opencontainers/selinux v1.11.0
|
github.com/opencontainers/selinux v1.11.0
|
||||||
github.com/openshift/imagebuilder v1.2.15
|
github.com/openshift/imagebuilder v1.2.15
|
||||||
github.com/rootless-containers/rootlesskit/v2 v2.3.1
|
github.com/rootless-containers/rootlesskit/v2 v2.3.1
|
||||||
github.com/shirou/gopsutil/v3 v3.24.5
|
github.com/shirou/gopsutil/v4 v4.24.8
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
|
4
go.sum
4
go.sum
@ -450,8 +450,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/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
github.com/shirou/gopsutil/v4 v4.24.8 h1:pVQjIenQkIhqO81mwTaXjTzOMT7d3TZkf43PlVFHENI=
|
||||||
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
|
github.com/shirou/gopsutil/v4 v4.24.8/go.mod h1:wE0OrJtj4dG+hYkxqDH3QiBICdKSf04/npcvLLc/oRg=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
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 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
. "github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec"
|
||||||
"github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v4/mem"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
psutil "github.com/shirou/gopsutil/v3/process"
|
psutil "github.com/shirou/gopsutil/v4/process"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
12
vendor/github.com/shirou/gopsutil/v3/net/net_linux_111.go
generated
vendored
12
vendor/github.com/shirou/gopsutil/v3/net/net_linux_111.go
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
//go:build !go1.16
|
|
||||||
// +build !go1.16
|
|
||||||
|
|
||||||
package net
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func readDir(f *os.File, max int) ([]os.FileInfo, error) {
|
|
||||||
return f.Readdir(max)
|
|
||||||
}
|
|
12
vendor/github.com/shirou/gopsutil/v3/net/net_linux_116.go
generated
vendored
12
vendor/github.com/shirou/gopsutil/v3/net/net_linux_116.go
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
//go:build go1.16
|
|
||||||
// +build go1.16
|
|
||||||
|
|
||||||
package net
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
func readDir(f *os.File, max int) ([]os.DirEntry, error) {
|
|
||||||
return f.ReadDir(max)
|
|
||||||
}
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
type EnvKeyType string
|
type EnvKeyType string
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -11,7 +12,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TimesStat contains the amounts of time the CPU has spent performing different
|
// TimesStat contains the amounts of time the CPU has spent performing different
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix
|
//go:build aix
|
||||||
// +build aix
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && cgo
|
//go:build aix && cgo
|
||||||
// +build aix,cgo
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && !cgo
|
//go:build aix && !cgo
|
||||||
// +build aix,!cgo
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
|
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && cgo
|
//go:build darwin && cgo
|
||||||
// +build darwin,cgo
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && !cgo
|
//go:build darwin && !cgo
|
||||||
// +build darwin,!cgo
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import "github.com/shirou/gopsutil/v3/internal/common"
|
import "github.com/shirou/gopsutil/v4/internal/common"
|
||||||
|
|
||||||
func perCPUTimes() ([]TimesStat, error) {
|
func perCPUTimes() ([]TimesStat, error) {
|
||||||
return []TimesStat{}, common.ErrNotImplementedError
|
return []TimesStat{}, common.ErrNotImplementedError
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build !darwin && !linux && !freebsd && !openbsd && !netbsd && !solaris && !windows && !dragonfly && !plan9 && !aix
|
//go:build !darwin && !linux && !freebsd && !openbsd && !netbsd && !solaris && !windows && !dragonfly && !plan9 && !aix
|
||||||
// +build !darwin,!linux,!freebsd,!openbsd,!netbsd,!solaris,!windows,!dragonfly,!plan9,!aix
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Times(percpu bool) ([]TimesStat, error) {
|
func Times(percpu bool) ([]TimesStat, error) {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -10,9 +11,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -135,7 +137,7 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
|
|||||||
c.Model = matches[4]
|
c.Model = matches[4]
|
||||||
t, err := strconv.ParseInt(matches[5], 10, 32)
|
t, err := strconv.ParseInt(matches[5], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %v", line, err)
|
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU stepping information from %q: %w", line, err)
|
||||||
}
|
}
|
||||||
c.Stepping = int32(t)
|
c.Stepping = int32(t)
|
||||||
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
|
} else if matches := featuresMatch.FindStringSubmatch(line); matches != nil {
|
||||||
@ -149,12 +151,12 @@ func parseDmesgBoot(fileName string) (InfoStat, int, error) {
|
|||||||
} else if matches := cpuCores.FindStringSubmatch(line); matches != nil {
|
} else if matches := cpuCores.FindStringSubmatch(line); matches != nil {
|
||||||
t, err := strconv.ParseInt(matches[1], 10, 32)
|
t, err := strconv.ParseInt(matches[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %v", line, err)
|
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU Nums from %q: %w", line, err)
|
||||||
}
|
}
|
||||||
cpuNum = int(t)
|
cpuNum = int(t)
|
||||||
t2, err := strconv.ParseInt(matches[2], 10, 32)
|
t2, err := strconv.ParseInt(matches[2], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %v", line, err)
|
return c, 0, fmt.Errorf("unable to parse FreeBSD CPU cores from %q: %w", line, err)
|
||||||
}
|
}
|
||||||
c.Cores = int32(t2)
|
c.Cores = int32(t2)
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ClocksPerSec = float64(100)
|
var ClocksPerSec = float64(100)
|
||||||
@ -395,7 +395,7 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) {
|
|||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
line = strings.ToLower(line)
|
line = strings.ToLower(line)
|
||||||
if strings.HasPrefix(line, "processor") {
|
if strings.HasPrefix(line, "processor") {
|
||||||
_, err = strconv.Atoi(strings.TrimSpace(line[strings.IndexByte(line, ':')+1:]))
|
_, err = strconv.ParseInt(strings.TrimSpace(line[strings.IndexByte(line, ':')+1:]), 10, 32)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ret++
|
ret++
|
||||||
}
|
}
|
||||||
@ -464,11 +464,11 @@ func CountsWithContext(ctx context.Context, logical bool) (int, error) {
|
|||||||
}
|
}
|
||||||
fields[0] = strings.TrimSpace(fields[0])
|
fields[0] = strings.TrimSpace(fields[0])
|
||||||
if fields[0] == "physical id" || fields[0] == "cpu cores" {
|
if fields[0] == "physical id" || fields[0] == "cpu cores" {
|
||||||
val, err := strconv.Atoi(strings.TrimSpace(fields[1]))
|
val, err := strconv.ParseInt(strings.TrimSpace(fields[1]), 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
currentInfo[fields[0]] = val
|
currentInfo[fields[0]] = int(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret := 0
|
ret := 0
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build netbsd
|
//go:build netbsd
|
||||||
// +build netbsd
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -9,9 +9,10 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
type cpuTimes struct {
|
type cpuTimes struct {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
// +build plan9
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
stats "github.com/lufia/plan9stats"
|
stats "github.com/lufia/plan9stats"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Times(percpu bool) ([]TimesStat, error) {
|
func Times(percpu bool) ([]TimesStat, error) {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
import (
|
import (
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
@ -8,14 +8,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/yusufpapurcu/wmi"
|
"github.com/yusufpapurcu/wmi"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
||||||
procGetNativeSystemInfo = common.Modkernel32.NewProc("GetNativeSystemInfo")
|
|
||||||
)
|
|
||||||
|
|
||||||
type win32_Processor struct {
|
type win32_Processor struct {
|
||||||
Family uint16
|
Family uint16
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -14,6 +15,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -25,7 +27,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/common"
|
"github.com/shirou/gopsutil/v4/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -152,7 +154,7 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
|
|||||||
var ret []string
|
var ret []string
|
||||||
|
|
||||||
r := bufio.NewReader(f)
|
r := bufio.NewReader(f)
|
||||||
for i := 0; i < n+int(offset) || n < 0; i++ {
|
for i := uint(0); i < uint(n)+offset || n < 0; i++ {
|
||||||
line, err := r.ReadString('\n')
|
line, err := r.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF && len(line) > 0 {
|
if err == io.EOF && len(line) > 0 {
|
||||||
@ -160,7 +162,7 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i < int(offset) {
|
if i < offset {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ret = append(ret, strings.Trim(line, "\n"))
|
ret = append(ret, strings.Trim(line, "\n"))
|
||||||
@ -462,3 +464,11 @@ func getSysctrlEnv(env []string) []string {
|
|||||||
}
|
}
|
||||||
return env
|
return env
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Round places rounds the number 'val' to 'n' decimal places
|
||||||
|
func Round(val float64, n int) float64 {
|
||||||
|
// Calculate the power of 10 to the n
|
||||||
|
pow10 := math.Pow(10, float64(n))
|
||||||
|
// Multiply the value by pow10, round it, then divide it by pow10
|
||||||
|
return math.Round(val*pow10) / pow10
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd || openbsd
|
//go:build freebsd || openbsd
|
||||||
// +build freebsd openbsd
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
||||||
@ -90,6 +90,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|||||||
if enableCache {
|
if enableCache {
|
||||||
atomic.StoreUint64(&cachedBootTime, t)
|
atomic.StoreUint64(&cachedBootTime, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := HostProcWithContext(ctx, "uptime")
|
filename := HostProcWithContext(ctx, "uptime")
|
||||||
@ -97,6 +99,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return handleBootTimeFileReadErr(err)
|
return handleBootTimeFileReadErr(err)
|
||||||
}
|
}
|
||||||
|
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
|
||||||
|
|
||||||
if len(lines) != 1 {
|
if len(lines) != 1 {
|
||||||
return 0, fmt.Errorf("wrong uptime format")
|
return 0, fmt.Errorf("wrong uptime format")
|
||||||
}
|
}
|
||||||
@ -105,7 +109,6 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
|
|
||||||
t := currentTime - b
|
t := currentTime - b
|
||||||
|
|
||||||
if enableCache {
|
if enableCache {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build netbsd
|
//go:build netbsd
|
||||||
// +build netbsd
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux || freebsd || darwin || openbsd
|
//go:build linux || freebsd || darwin || openbsd
|
||||||
// +build linux freebsd darwin openbsd
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package common
|
package common
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package common
|
package common
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
40
vendor/github.com/shirou/gopsutil/v4/mem/ex_linux.go
generated
vendored
Normal file
40
vendor/github.com/shirou/gopsutil/v4/mem/ex_linux.go
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
//go:build linux
|
||||||
|
|
||||||
|
package mem
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExVirtualMemory struct {
|
||||||
|
ActiveFile uint64 `json:"activefile"`
|
||||||
|
InactiveFile uint64 `json:"inactivefile"`
|
||||||
|
ActiveAnon uint64 `json:"activeanon"`
|
||||||
|
InactiveAnon uint64 `json:"inactiveanon"`
|
||||||
|
Unevictable uint64 `json:"unevictable"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v ExVirtualMemory) String() string {
|
||||||
|
s, _ := json.Marshal(v)
|
||||||
|
return string(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExLinux struct{}
|
||||||
|
|
||||||
|
func NewExLinux() *ExLinux {
|
||||||
|
return &ExLinux{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex *ExLinux) VirtualMemory() (*ExVirtualMemory, error) {
|
||||||
|
return ex.VirtualMemoryWithContext(context.Background())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ex *ExLinux) VirtualMemoryWithContext(ctx context.Context) (*ExVirtualMemory, error) {
|
||||||
|
_, vmEx, err := fillFromMeminfoWithContext(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return vmEx, nil
|
||||||
|
}
|
39
vendor/github.com/shirou/gopsutil/v4/mem/ex_windows.go
generated
vendored
Normal file
39
vendor/github.com/shirou/gopsutil/v4/mem/ex_windows.go
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package mem
|
||||||
|
|
||||||
|
import (
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExVirtualMemory represents Windows specific information
|
||||||
|
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex
|
||||||
|
type ExVirtualMemory struct {
|
||||||
|
VirtualTotal uint64 `json:"virtualTotal"`
|
||||||
|
VirtualAvail uint64 `json:"virtualAvail"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExWindows struct{}
|
||||||
|
|
||||||
|
func NewExWindows() *ExWindows {
|
||||||
|
return &ExWindows{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ExWindows) VirtualMemory() (*ExVirtualMemory, error) {
|
||||||
|
var memInfo memoryStatusEx
|
||||||
|
memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
|
||||||
|
mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo)))
|
||||||
|
if mem == 0 {
|
||||||
|
return nil, windows.GetLastError()
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := &ExVirtualMemory{
|
||||||
|
VirtualTotal: memInfo.ullTotalVirtual,
|
||||||
|
VirtualAvail: memInfo.ullAvailVirtual,
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret, nil
|
||||||
|
}
|
@ -1,9 +1,10 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var invoke common.Invoker = common.Invoke{}
|
var invoke common.Invoker = common.Invoke{}
|
@ -1,10 +1,12 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix
|
//go:build aix
|
||||||
// +build aix
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
@ -14,3 +16,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
|||||||
func SwapMemory() (*SwapMemoryStat, error) {
|
func SwapMemory() (*SwapMemoryStat, error) {
|
||||||
return SwapMemoryWithContext(context.Background())
|
return SwapMemoryWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SwapDevices() ([]*SwapDevice, error) {
|
||||||
|
return nil, common.ErrNotImplementedError
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && cgo
|
//go:build aix && cgo
|
||||||
// +build aix,cgo
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && !cgo
|
//go:build aix && !cgo
|
||||||
// +build aix,!cgo
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
|
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd || openbsd || netbsd
|
//go:build freebsd || openbsd || netbsd
|
||||||
// +build freebsd openbsd netbsd
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getHwMemsize() (uint64, error) {
|
func getHwMemsize() (uint64, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && cgo
|
//go:build darwin && cgo
|
||||||
// +build darwin,cgo
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && !cgo
|
//go:build darwin && !cgo
|
||||||
// +build darwin,!cgo
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build !darwin && !linux && !freebsd && !openbsd && !solaris && !windows && !plan9 && !aix && !netbsd
|
//go:build !darwin && !linux && !freebsd && !openbsd && !solaris && !windows && !plan9 && !aix && !netbsd
|
||||||
// +build !darwin,!linux,!freebsd,!openbsd,!solaris,!windows,!plan9,!aix,!netbsd
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
func VirtualMemory() (*VirtualMemoryStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -8,8 +8,9 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
@ -85,7 +86,6 @@ func SwapMemory() (*SwapMemoryStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constants from vm/vm_param.h
|
// Constants from vm/vm_param.h
|
||||||
// nolint: golint
|
|
||||||
const (
|
const (
|
||||||
XSWDEV_VERSION11 = 1
|
XSWDEV_VERSION11 = 1
|
||||||
XSWDEV_VERSION = 2
|
XSWDEV_VERSION = 2
|
@ -1,12 +1,11 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
@ -16,22 +15,9 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VirtualMemoryExStat struct {
|
|
||||||
ActiveFile uint64 `json:"activefile"`
|
|
||||||
InactiveFile uint64 `json:"inactivefile"`
|
|
||||||
ActiveAnon uint64 `json:"activeanon"`
|
|
||||||
InactiveAnon uint64 `json:"inactiveanon"`
|
|
||||||
Unevictable uint64 `json:"unevictable"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v VirtualMemoryExStat) String() string {
|
|
||||||
s, _ := json.Marshal(v)
|
|
||||||
return string(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func VirtualMemory() (*VirtualMemoryStat, error) {
|
func VirtualMemory() (*VirtualMemoryStat, error) {
|
||||||
return VirtualMemoryWithContext(context.Background())
|
return VirtualMemoryWithContext(context.Background())
|
||||||
}
|
}
|
||||||
@ -44,19 +30,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
|
|||||||
return vm, nil
|
return vm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func VirtualMemoryEx() (*VirtualMemoryExStat, error) {
|
func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *ExVirtualMemory, error) {
|
||||||
return VirtualMemoryExWithContext(context.Background())
|
|
||||||
}
|
|
||||||
|
|
||||||
func VirtualMemoryExWithContext(ctx context.Context) (*VirtualMemoryExStat, error) {
|
|
||||||
_, vmEx, err := fillFromMeminfoWithContext(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return vmEx, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *VirtualMemoryExStat, error) {
|
|
||||||
filename := common.HostProcWithContext(ctx, "meminfo")
|
filename := common.HostProcWithContext(ctx, "meminfo")
|
||||||
lines, _ := common.ReadLines(filename)
|
lines, _ := common.ReadLines(filename)
|
||||||
|
|
||||||
@ -67,7 +41,7 @@ func fillFromMeminfoWithContext(ctx context.Context) (*VirtualMemoryStat, *Virtu
|
|||||||
sReclaimable := false // "Sreclaimable:" not available: 2.6.19 / Nov 2006
|
sReclaimable := false // "Sreclaimable:" not available: 2.6.19 / Nov 2006
|
||||||
|
|
||||||
ret := &VirtualMemoryStat{}
|
ret := &VirtualMemoryStat{}
|
||||||
retEx := &VirtualMemoryExStat{}
|
retEx := &ExVirtualMemory{}
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
fields := strings.Split(line, ":")
|
fields := strings.Split(line, ":")
|
||||||
@ -409,7 +383,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
|
|||||||
// calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide
|
// calculateAvailVmem is a fallback under kernel 3.14 where /proc/meminfo does not provide
|
||||||
// "MemAvailable:" column. It reimplements an algorithm from the link below
|
// "MemAvailable:" column. It reimplements an algorithm from the link below
|
||||||
// https://github.com/giampaolo/psutil/pull/890
|
// https://github.com/giampaolo/psutil/pull/890
|
||||||
func calculateAvailVmem(ctx context.Context, ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint64 {
|
func calculateAvailVmem(ctx context.Context, ret *VirtualMemoryStat, retEx *ExVirtualMemory) uint64 {
|
||||||
var watermarkLow uint64
|
var watermarkLow uint64
|
||||||
|
|
||||||
fn := common.HostProcWithContext(ctx, "zoneinfo")
|
fn := common.HostProcWithContext(ctx, "zoneinfo")
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build netbsd
|
//go:build netbsd
|
||||||
// +build netbsd
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd && 386
|
//go:build openbsd && 386
|
||||||
// +build openbsd,386
|
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs mem/types_openbsd.go
|
// cgo -godefs mem/types_openbsd.go
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Created by cgo -godefs - DO NOT EDIT
|
||||||
// cgo -godefs types_openbsd.go
|
// cgo -godefs types_openbsd.go
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd && arm
|
//go:build openbsd && arm
|
||||||
// +build openbsd,arm
|
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs mem/types_openbsd.go
|
// cgo -godefs mem/types_openbsd.go
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd && arm64
|
//go:build openbsd && arm64
|
||||||
// +build openbsd,arm64
|
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs mem/types_openbsd.go
|
// cgo -godefs mem/types_openbsd.go
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd && riscv64
|
//go:build openbsd && riscv64
|
||||||
// +build openbsd,riscv64
|
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs mem/types_openbsd.go
|
// cgo -godefs mem/types_openbsd.go
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
// +build plan9
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
stats "github.com/lufia/plan9stats"
|
stats "github.com/lufia/plan9stats"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SwapMemory() (*SwapMemoryStat, error) {
|
func SwapMemory() (*SwapMemoryStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build solaris
|
//go:build solaris
|
||||||
// +build solaris
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
)
|
)
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package mem
|
package mem
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,26 +77,40 @@ func SwapMemory() (*SwapMemoryStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
|
func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
|
||||||
|
// Use the performance counter to get the swap usage percentage
|
||||||
|
counter, err := common.NewWin32PerformanceCounter("swap_percentage", `\Paging File(_Total)\% Usage`)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
usedPercent, err := counter.GetValue()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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))
|
mem, _, _ := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&perfInfo)), uintptr(perfInfo.cb))
|
||||||
if mem == 0 {
|
if mem == 0 {
|
||||||
return nil, windows.GetLastError()
|
return nil, windows.GetLastError()
|
||||||
}
|
}
|
||||||
tot := perfInfo.commitLimit * perfInfo.pageSize
|
totalPhys := perfInfo.physicalTotal * perfInfo.pageSize
|
||||||
used := perfInfo.commitTotal * perfInfo.pageSize
|
totalSys := perfInfo.commitLimit * perfInfo.pageSize
|
||||||
free := tot - used
|
total := totalSys - totalPhys
|
||||||
var usedPercent float64
|
|
||||||
if tot == 0 {
|
var used uint64
|
||||||
usedPercent = 0
|
if total > 0 {
|
||||||
|
used = uint64(0.01 * usedPercent * float64(total))
|
||||||
} else {
|
} else {
|
||||||
usedPercent = float64(used) / float64(tot) * 100
|
usedPercent = 0.0
|
||||||
|
used = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := &SwapMemoryStat{
|
ret := &SwapMemoryStat{
|
||||||
Total: tot,
|
Total: total,
|
||||||
Used: used,
|
Used: used,
|
||||||
Free: free,
|
Free: total - used,
|
||||||
UsedPercent: usedPercent,
|
UsedPercent: common.Round(usedPercent, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -5,7 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var invoke common.Invoker = common.Invoke{}
|
var invoke common.Invoker = common.Invoke{}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix
|
//go:build aix
|
||||||
// +build aix
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||||
@ -117,7 +117,7 @@ func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, r
|
|||||||
return Addr{}, fmt.Errorf("unknown family, %d", family)
|
return Addr{}, fmt.Errorf("unknown family, %d", family)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lport, err := strconv.Atoi(port)
|
lport, err := strconv.ParseInt(port, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Addr{}, err
|
return Addr{}, err
|
||||||
}
|
}
|
||||||
@ -286,11 +286,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsMaxWithContext(context.Background(), kind, max)
|
return ConnectionsMaxWithContext(context.Background(), kind, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,8 +305,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
|
|||||||
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
||||||
@ -317,14 +317,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
|
|||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && cgo
|
//go:build aix && cgo
|
||||||
// +build aix,cgo
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build aix && !cgo
|
//go:build aix && !cgo
|
||||||
// +build aix,!cgo
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseNetstatI(output string) ([]IOCountersStat, error) {
|
func parseNetstatI(output string) ([]IOCountersStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -143,8 +143,8 @@ func newMapInterfaceNameUsage(ifaces []netstatInterface) mapInterfaceNameUsage {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
func (min mapInterfaceNameUsage) isTruncated() bool {
|
func (mapi mapInterfaceNameUsage) isTruncated() bool {
|
||||||
for _, usage := range min {
|
for _, usage := range mapi {
|
||||||
if usage > 1 {
|
if usage > 1 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -152,9 +152,9 @@ func (min mapInterfaceNameUsage) isTruncated() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (min mapInterfaceNameUsage) notTruncated() []string {
|
func (mapi mapInterfaceNameUsage) notTruncated() []string {
|
||||||
output := make([]string, 0)
|
output := make([]string, 0)
|
||||||
for ifaceName, usage := range min {
|
for ifaceName, usage := range mapi {
|
||||||
if usage == 1 {
|
if usage == 1 {
|
||||||
output = append(output, ifaceName)
|
output = append(output, ifaceName)
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if pernic == false {
|
if !pernic {
|
||||||
return getIOCountersAll(ret)
|
return getIOCountersAll(ret)
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
@ -1,12 +1,12 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build !aix && !darwin && !linux && !freebsd && !openbsd && !windows && !solaris
|
//go:build !aix && !darwin && !linux && !freebsd && !openbsd && !windows && !solaris
|
||||||
// +build !aix,!darwin,!linux,!freebsd,!openbsd,!windows,!solaris
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||||
@ -49,11 +49,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
|
|||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsMaxWithContext(context.Background(), kind, max)
|
return ConnectionsMaxWithContext(context.Background(), kind, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +68,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
|
|||||||
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
||||||
@ -80,14 +80,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
|
|||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
func IOCounters(pernic bool) ([]IOCountersStat, error) {
|
||||||
@ -83,7 +83,7 @@ func IOCountersWithContext(ctx context.Context, pernic bool) ([]IOCountersStat,
|
|||||||
ret = append(ret, n)
|
ret = append(ret, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pernic == false {
|
if !pernic {
|
||||||
return getIOCountersAll(ret)
|
return getIOCountersAll(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ func IOCountersByFile(pernic bool, filename string) ([]IOCountersStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
|
func IOCountersByFileWithContext(ctx context.Context, pernic bool, filename string) ([]IOCountersStat, error) {
|
||||||
return IOCounters(pernic)
|
return IOCountersWithContext(ctx, pernic)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FilterCounters() ([]FilterStat, error) {
|
func FilterCounters() ([]FilterStat, error) {
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ( // Conntrack Column numbers
|
const ( // Conntrack Column numbers
|
||||||
@ -238,14 +238,14 @@ func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
|
|||||||
}
|
}
|
||||||
stats := make([]FilterStat, 0, 1)
|
stats := make([]FilterStat, 0, 1)
|
||||||
|
|
||||||
max, err := common.ReadInts(maxfile)
|
maxConn, err := common.ReadInts(maxfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
payload := FilterStat{
|
payload := FilterStat{
|
||||||
ConnTrackCount: count[0],
|
ConnTrackCount: count[0],
|
||||||
ConnTrackMax: max[0],
|
ConnTrackMax: maxConn[0],
|
||||||
}
|
}
|
||||||
|
|
||||||
stats = append(stats, payload)
|
stats = append(stats, payload)
|
||||||
@ -396,12 +396,12 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
|
|||||||
|
|
||||||
// Return a list of network connections opened returning at most `max`
|
// Return a list of network connections opened returning at most `max`
|
||||||
// connections for each running process.
|
// connections for each running process.
|
||||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsMaxWithContext(context.Background(), kind, max)
|
return ConnectionsMaxWithContext(context.Background(), kind, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of network connections opened, omitting `Uids`.
|
// Return a list of network connections opened, omitting `Uids`.
|
||||||
@ -415,8 +415,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
|
|||||||
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of network connections opened by a process.
|
// Return a list of network connections opened by a process.
|
||||||
@ -437,23 +437,23 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return up to `max` network connections opened by a process.
|
// Return up to `max` network connections opened by a process.
|
||||||
func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMax(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max, false)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max, true)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int, skipUids bool) ([]ConnectionStat, error) {
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int, skipUids bool) ([]ConnectionStat, error) {
|
||||||
tmap, ok := netConnectionKindMap[kind]
|
tmap, ok := netConnectionKindMap[kind]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid kind, %s", kind)
|
return nil, fmt.Errorf("invalid kind, %s", kind)
|
||||||
@ -462,9 +462,9 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p
|
|||||||
var err error
|
var err error
|
||||||
var inodes map[string][]inodeMap
|
var inodes map[string][]inodeMap
|
||||||
if pid == 0 {
|
if pid == 0 {
|
||||||
inodes, err = getProcInodesAllWithContext(ctx, root, max)
|
inodes, err = getProcInodesAllWithContext(ctx, root, maxConn)
|
||||||
} else {
|
} else {
|
||||||
inodes, err = getProcInodes(root, pid, max)
|
inodes, err = getProcInodes(root, pid, maxConn)
|
||||||
if len(inodes) == 0 {
|
if len(inodes) == 0 {
|
||||||
// no connection for the pid
|
// no connection for the pid
|
||||||
return []ConnectionStat{}, nil
|
return []ConnectionStat{}, nil
|
||||||
@ -543,7 +543,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getProcInodes returns fd of the pid.
|
// getProcInodes returns fd of the pid.
|
||||||
func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, error) {
|
func getProcInodes(root string, pid int32, maxConn int) (map[string][]inodeMap, error) {
|
||||||
ret := make(map[string][]inodeMap)
|
ret := make(map[string][]inodeMap)
|
||||||
|
|
||||||
dir := fmt.Sprintf("%s/%d/fd", root, pid)
|
dir := fmt.Sprintf("%s/%d/fd", root, pid)
|
||||||
@ -552,7 +552,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro
|
|||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
dirEntries, err := readDir(f, max)
|
dirEntries, err := f.ReadDir(maxConn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro
|
|||||||
if !ok {
|
if !ok {
|
||||||
ret[inode] = make([]inodeMap, 0)
|
ret[inode] = make([]inodeMap, 0)
|
||||||
}
|
}
|
||||||
fd, err := strconv.Atoi(dirEntry.Name())
|
fd, err := strconv.ParseInt(dirEntry.Name(), 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -668,11 +668,11 @@ func (p *process) fillFromStatus(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProcInodesAll(root string, max int) (map[string][]inodeMap, error) {
|
func getProcInodesAll(root string, maxConn int) (map[string][]inodeMap, error) {
|
||||||
return getProcInodesAllWithContext(context.Background(), root, max)
|
return getProcInodesAllWithContext(context.Background(), root, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProcInodesAllWithContext(ctx context.Context, root string, max int) (map[string][]inodeMap, error) {
|
func getProcInodesAllWithContext(ctx context.Context, root string, maxConn int) (map[string][]inodeMap, error) {
|
||||||
pids, err := PidsWithContext(ctx)
|
pids, err := PidsWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -680,7 +680,7 @@ func getProcInodesAllWithContext(ctx context.Context, root string, max int) (map
|
|||||||
ret := make(map[string][]inodeMap)
|
ret := make(map[string][]inodeMap)
|
||||||
|
|
||||||
for _, pid := range pids {
|
for _, pid := range pids {
|
||||||
t, err := getProcInodes(root, pid, max)
|
t, err := getProcInodes(root, pid, maxConn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// skip if permission error or no longer exists
|
// skip if permission error or no longer exists
|
||||||
if os.IsPermission(err) || os.IsNotExist(err) || errors.Is(err, io.EOF) {
|
if os.IsPermission(err) || os.IsNotExist(err) || errors.Is(err, io.EOF) {
|
||||||
@ -858,7 +858,7 @@ func processUnix(file string, kind netConnectionKindType, inodes map[string][]in
|
|||||||
if len(tokens) < 6 {
|
if len(tokens) < 6 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
st, err := strconv.Atoi(tokens[4])
|
st, err := strconv.ParseInt(tokens[4], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -12,13 +12,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`)
|
var portMatch = regexp.MustCompile(`(.*)\.(\d+)$`)
|
||||||
|
|
||||||
func ParseNetstat(output string, mode string,
|
func ParseNetstat(output string, mode string,
|
||||||
iocs map[string]IOCountersStat) error {
|
iocs map[string]IOCountersStat,
|
||||||
|
) error {
|
||||||
lines := strings.Split(output, "\n")
|
lines := strings.Split(output, "\n")
|
||||||
|
|
||||||
exists := make([]string, 0, len(lines)-1)
|
exists := make([]string, 0, len(lines)-1)
|
||||||
@ -96,7 +97,7 @@ func ParseNetstat(output string, mode string,
|
|||||||
n.PacketsSent = parsed[2]
|
n.PacketsSent = parsed[2]
|
||||||
n.Dropout = parsed[3]
|
n.Dropout = parsed[3]
|
||||||
case "ine":
|
case "ine":
|
||||||
n.Errin = parsed[0]
|
n.Errin = parsed[0]
|
||||||
n.Errout = parsed[1]
|
n.Errout = parsed[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +255,7 @@ func parseNetstatAddr(local string, remote string, family uint32) (laddr Addr, r
|
|||||||
return Addr{}, fmt.Errorf("unknown family, %d", family)
|
return Addr{}, fmt.Errorf("unknown family, %d", family)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lport, err := strconv.Atoi(port)
|
lport, err := strconv.ParseInt(port, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Addr{}, err
|
return Addr{}, err
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build solaris
|
//go:build solaris
|
||||||
// +build solaris
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetIOCounters returnes network I/O statistics for every network
|
// NetIOCounters returnes network I/O statistics for every network
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd || darwin
|
//go:build freebsd || darwin
|
||||||
// +build freebsd darwin
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Return a list of network connections opened.
|
// Return a list of network connections opened.
|
||||||
@ -25,11 +25,11 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
|
|||||||
|
|
||||||
// Return a list of network connections opened returning at most `max`
|
// Return a list of network connections opened returning at most `max`
|
||||||
// connections for each running process.
|
// connections for each running process.
|
||||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsMaxWithContext(context.Background(), kind, max)
|
return ConnectionsMaxWithContext(context.Background(), kind, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ func parseNetLine(line string) (ConnectionStat, error) {
|
|||||||
f[7] = "unix"
|
f[7] = "unix"
|
||||||
}
|
}
|
||||||
|
|
||||||
pid, err := strconv.Atoi(f[1])
|
pid, err := strconv.ParseInt(f[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ConnectionStat{}, err
|
return ConnectionStat{}, err
|
||||||
}
|
}
|
||||||
fd, err := strconv.Atoi(strings.Trim(f[3], "u"))
|
fd, err := strconv.ParseInt(strings.Trim(f[3], "u"), 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ConnectionStat{}, fmt.Errorf("unknown fd, %s", f[3])
|
return ConnectionStat{}, fmt.Errorf("unknown fd, %s", f[3])
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return Addr{}, fmt.Errorf("wrong addr, %s", l)
|
return Addr{}, fmt.Errorf("wrong addr, %s", l)
|
||||||
}
|
}
|
||||||
lport, err := strconv.Atoi(port)
|
lport, err := strconv.ParseInt(port, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Addr{}, err
|
return Addr{}, err
|
||||||
}
|
}
|
||||||
@ -180,11 +180,11 @@ func parseNetAddr(line string) (laddr Addr, raddr Addr, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return up to `max` network connections opened by a process.
|
// Return up to `max` network connections opened by a process.
|
||||||
func ConnectionsPidMax(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMax(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,8 +199,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
|
|||||||
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
||||||
@ -211,14 +211,14 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
|
|||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -279,11 +279,11 @@ func getNetStatWithKind(kindType netConnectionKindType) ([]ConnectionStat, error
|
|||||||
|
|
||||||
// Return a list of network connections opened returning at most `max`
|
// Return a list of network connections opened returning at most `max`
|
||||||
// connections for each running process.
|
// connections for each running process.
|
||||||
func ConnectionsMax(kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMax(kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsMaxWithContext(context.Background(), kind, max)
|
return ConnectionsMaxWithContext(context.Background(), kind, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,8 +298,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
|
|||||||
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
return ConnectionsMaxWithoutUidsWithContext(ctx, kind, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, max int) ([]ConnectionStat, error) {
|
func ConnectionsMaxWithoutUidsWithContext(ctx context.Context, kind string, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, 0, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
func ConnectionsPidWithoutUids(kind string, pid int32) ([]ConnectionStat, error) {
|
||||||
@ -310,15 +310,15 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
|
|||||||
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
return ConnectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUids(kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUids(kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, max)
|
return ConnectionsPidMaxWithoutUidsWithContext(context.Background(), kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func ConnectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, max)
|
return connectionsPidMaxWithoutUidsWithContext(ctx, kind, pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, max int) ([]ConnectionStat, error) {
|
func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, pid int32, maxConn int) ([]ConnectionStat, error) {
|
||||||
return []ConnectionStat{}, common.ErrNotImplementedError
|
return []ConnectionStat{}, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
package process
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -9,10 +10,10 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/shirou/gopsutil/v3/mem"
|
"github.com/shirou/gopsutil/v4/mem"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -29,9 +30,9 @@ type Process struct {
|
|||||||
parent int32
|
parent int32
|
||||||
parentMutex sync.RWMutex // for windows ppid cache
|
parentMutex sync.RWMutex // for windows ppid cache
|
||||||
numCtxSwitches *NumCtxSwitchesStat
|
numCtxSwitches *NumCtxSwitchesStat
|
||||||
uids []int32
|
uids []uint32
|
||||||
gids []int32
|
gids []uint32
|
||||||
groups []int32
|
groups []uint32
|
||||||
numThreads int32
|
numThreads int32
|
||||||
memInfo *MemoryInfoStat
|
memInfo *MemoryInfoStat
|
||||||
sigInfo *SignalInfoStat
|
sigInfo *SignalInfoStat
|
||||||
@ -102,10 +103,18 @@ type RlimitStat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IOCountersStat struct {
|
type IOCountersStat struct {
|
||||||
ReadCount uint64 `json:"readCount"`
|
// ReadCount is a number of read I/O operations such as syscalls.
|
||||||
|
ReadCount uint64 `json:"readCount"`
|
||||||
|
// WriteCount is a number of read I/O operations such as syscalls.
|
||||||
WriteCount uint64 `json:"writeCount"`
|
WriteCount uint64 `json:"writeCount"`
|
||||||
ReadBytes uint64 `json:"readBytes"`
|
// ReadBytes is a number of all I/O read in bytes. This includes disk I/O on Linux and Windows.
|
||||||
|
ReadBytes uint64 `json:"readBytes"`
|
||||||
|
// WriteBytes is a number of all I/O write in bytes. This includes disk I/O on Linux and Windows.
|
||||||
WriteBytes uint64 `json:"writeBytes"`
|
WriteBytes uint64 `json:"writeBytes"`
|
||||||
|
// DiskReadBytes is a number of disk I/O write in bytes. Currently only Linux has this value.
|
||||||
|
DiskReadBytes uint64 `json:"diskReadBytes"`
|
||||||
|
// DiskWriteBytes is a number of disk I/O read in bytes. Currently only Linux has this value.
|
||||||
|
DiskWriteBytes uint64 `json:"diskWriteBytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NumCtxSwitchesStat struct {
|
type NumCtxSwitchesStat struct {
|
||||||
@ -316,7 +325,11 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64
|
|||||||
if delta == 0 {
|
if delta == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
delta_proc := t2.Total() - t1.Total()
|
// https://github.com/giampaolo/psutil/blob/c034e6692cf736b5e87d14418a8153bb03f6cf42/psutil/__init__.py#L1064
|
||||||
|
delta_proc := (t2.User - t1.User) + (t2.System - t1.System)
|
||||||
|
if delta_proc <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
|
overall_percent := ((delta_proc / delta) * 100) * float64(numcpu)
|
||||||
return overall_percent
|
return overall_percent
|
||||||
}
|
}
|
||||||
@ -368,7 +381,7 @@ func (p *Process) CPUPercentWithContext(ctx context.Context) (float64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Groups returns all group IDs(include supplementary groups) of the process as a slice of the int
|
// Groups returns all group IDs(include supplementary groups) of the process as a slice of the int
|
||||||
func (p *Process) Groups() ([]int32, error) {
|
func (p *Process) Groups() ([]uint32, error) {
|
||||||
return p.GroupsWithContext(context.Background())
|
return p.GroupsWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,12 +446,12 @@ func (p *Process) Foreground() (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Uids returns user ids of the process as a slice of the int
|
// Uids returns user ids of the process as a slice of the int
|
||||||
func (p *Process) Uids() ([]int32, error) {
|
func (p *Process) Uids() ([]uint32, error) {
|
||||||
return p.UidsWithContext(context.Background())
|
return p.UidsWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gids returns group ids of the process as a slice of the int
|
// Gids returns group ids of the process as a slice of the int
|
||||||
func (p *Process) Gids() ([]int32, error) {
|
func (p *Process) Gids() ([]uint32, error) {
|
||||||
return p.GidsWithContext(context.Background())
|
return p.GidsWithContext(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,8 +551,8 @@ func (p *Process) Connections() ([]net.ConnectionStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`.
|
// ConnectionsMax returns a slice of net.ConnectionStat used by the process at most `max`.
|
||||||
func (p *Process) ConnectionsMax(max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMax(maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return p.ConnectionsMaxWithContext(context.Background(), max)
|
return p.ConnectionsMaxWithContext(context.Background(), maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MemoryMaps get memory maps from /proc/(pid)/smaps
|
// MemoryMaps get memory maps from /proc/(pid)/smaps
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin || freebsd || openbsd
|
//go:build darwin || freebsd || openbsd
|
||||||
// +build darwin freebsd openbsd
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MemoryInfoExStat struct{}
|
type MemoryInfoExStat struct{}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
// copied from sys/sysctl.h
|
// copied from sys/sysctl.h
|
||||||
@ -117,31 +117,31 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
return strings.IndexByte(string(out), '+') != -1, nil
|
return strings.IndexByte(string(out), '+') != -1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// See: http://unix.superglobalmegacorp.com/Net2/newsrc/sys/ucred.h.html
|
// See: http://unix.superglobalmegacorp.com/Net2/newsrc/sys/ucred.h.html
|
||||||
userEffectiveUID := int32(k.Eproc.Ucred.Uid)
|
userEffectiveUID := uint32(k.Eproc.Ucred.Uid)
|
||||||
|
|
||||||
return []int32{userEffectiveUID}, nil
|
return []uint32{userEffectiveUID}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
gids := make([]int32, 0, 3)
|
gids := make([]uint32, 0, 3)
|
||||||
gids = append(gids, int32(k.Eproc.Pcred.P_rgid), int32(k.Eproc.Pcred.P_rgid), int32(k.Eproc.Pcred.P_svgid))
|
gids = append(gids, uint32(k.Eproc.Pcred.P_rgid), uint32(k.Eproc.Pcred.P_rgid), uint32(k.Eproc.Pcred.P_svgid))
|
||||||
|
|
||||||
return gids, nil
|
return gids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
// k, err := p.getKProc()
|
// k, err := p.getKProc()
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
@ -193,24 +193,24 @@ func convertCPUTimes(s string) (ret float64, err error) {
|
|||||||
_t := strings.Split(s, ":")
|
_t := strings.Split(s, ":")
|
||||||
switch len(_t) {
|
switch len(_t) {
|
||||||
case 3:
|
case 3:
|
||||||
hour, err := strconv.Atoi(_t[0])
|
hour, err := strconv.ParseInt(_t[0], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
t += hour * 60 * 60 * clockTicks
|
t += int(hour) * 60 * 60 * clockTicks
|
||||||
|
|
||||||
mins, err := strconv.Atoi(_t[1])
|
mins, err := strconv.ParseInt(_t[1], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
t += mins * 60 * clockTicks
|
t += int(mins) * 60 * clockTicks
|
||||||
_tmp = _t[2]
|
_tmp = _t[2]
|
||||||
case 2:
|
case 2:
|
||||||
mins, err := strconv.Atoi(_t[0])
|
mins, err := strconv.ParseInt(_t[0], 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
t += mins * 60 * clockTicks
|
t += int(mins) * 60 * clockTicks
|
||||||
_tmp = _t[1]
|
_tmp = _t[1]
|
||||||
case 1, 0:
|
case 1, 0:
|
||||||
_tmp = s
|
_tmp = s
|
||||||
@ -225,10 +225,10 @@ func convertCPUTimes(s string) (ret float64, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
h, err := strconv.Atoi(_t[0])
|
h, err := strconv.ParseInt(_t[0], 10, 32)
|
||||||
t += h * clockTicks
|
t += int(h) * clockTicks
|
||||||
h, err = strconv.Atoi(_t[1])
|
h, err = strconv.ParseInt(_t[1], 10, 32)
|
||||||
t += h
|
t += int(h)
|
||||||
return float64(t) / float64(clockTicks), nil
|
return float64(t) / float64(clockTicks), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +252,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
|
|||||||
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max)
|
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
|
func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Created by cgo -godefs - DO NOT EDIT
|
||||||
// cgo -godefs types_darwin.go
|
// cgo -godefs types_darwin.go
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && arm64
|
//go:build darwin && arm64
|
||||||
// +build darwin,arm64
|
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
||||||
// cgo -godefs process/types_darwin.go
|
// cgo -godefs process/types_darwin.go
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && cgo
|
//go:build darwin && cgo
|
||||||
// +build darwin,cgo
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build darwin && !cgo
|
//go:build darwin && !cgo
|
||||||
// +build darwin,!cgo
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -9,8 +9,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
|
func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
|
||||||
@ -20,7 +20,7 @@ func (p *Process) CwdWithContext(ctx context.Context) (string, error) {
|
|||||||
func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
|
func (p *Process) ExeWithContext(ctx context.Context) (string, error) {
|
||||||
out, err := invoke.CommandWithContext(ctx, "lsof", "-p", strconv.Itoa(int(p.Pid)), "-Fpfn")
|
out, err := invoke.CommandWithContext(ctx, "lsof", "-p", strconv.Itoa(int(p.Pid)), "-Fpfn")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("bad call to lsof: %s", err)
|
return "", fmt.Errorf("bad call to lsof: %w", err)
|
||||||
}
|
}
|
||||||
txtFound := 0
|
txtFound := 0
|
||||||
lines := strings.Split(string(out), "\n")
|
lines := strings.Split(string(out), "\n")
|
||||||
@ -111,15 +111,15 @@ func (p *Process) MemoryInfoWithContext(ctx context.Context) (*MemoryInfoStat, e
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rss, err := strconv.Atoi(r[0][0])
|
rss, err := strconv.ParseInt(r[0][0], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
vms, err := strconv.Atoi(r[0][1])
|
vms, err := strconv.ParseInt(r[0][1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pagein, err := strconv.Atoi(r[0][2])
|
pagein, err := strconv.ParseInt(r[0][2], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build !darwin && !linux && !freebsd && !openbsd && !windows && !solaris && !plan9
|
//go:build !darwin && !linux && !freebsd && !openbsd && !windows && !solaris && !plan9
|
||||||
// +build !darwin,!linux,!freebsd,!openbsd,!windows,!solaris,!plan9
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -7,9 +7,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Signal = syscall.Signal
|
type Signal = syscall.Signal
|
||||||
@ -82,15 +82,15 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
return false, common.ErrNotImplementedError
|
return false, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
|
|||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,21 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
cpu "github.com/shirou/gopsutil/v3/cpu"
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
net "github.com/shirou/gopsutil/v3/net"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
cpu "github.com/shirou/gopsutil/v4/cpu"
|
||||||
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
|
net "github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pidsWithContext(ctx context.Context) ([]int32, error) {
|
func pidsWithContext(ctx context.Context) ([]int32, error) {
|
||||||
@ -83,10 +85,7 @@ func (p *Process) CmdlineWithContext(ctx context.Context) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
ret := strings.FieldsFunc(string(buf), func(r rune) bool {
|
ret := strings.FieldsFunc(string(buf), func(r rune) bool {
|
||||||
if r == '\u0000' {
|
return r == '\u0000'
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return strings.Join(ret, " "), nil
|
return strings.Join(ret, " "), nil
|
||||||
@ -157,40 +156,40 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
return strings.IndexByte(string(out), '+') != -1, nil
|
return strings.IndexByte(string(out), '+') != -1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
uids := make([]int32, 0, 3)
|
uids := make([]uint32, 0, 3)
|
||||||
|
|
||||||
uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid))
|
uids = append(uids, uint32(k.Ruid), uint32(k.Uid), uint32(k.Svuid))
|
||||||
|
|
||||||
return uids, nil
|
return uids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
gids := make([]int32, 0, 3)
|
gids := make([]uint32, 0, 3)
|
||||||
gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid))
|
gids = append(gids, uint32(k.Rgid), uint32(k.Ngroups), uint32(k.Svgid))
|
||||||
|
|
||||||
return gids, nil
|
return gids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
groups := make([]int32, k.Ngroups)
|
groups := make([]uint32, k.Ngroups)
|
||||||
for i := int16(0); i < k.Ngroups; i++ {
|
for i := int16(0); i < k.Ngroups; i++ {
|
||||||
groups[i] = int32(k.Groups[i])
|
groups[i] = uint32(k.Groups[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups, nil
|
return groups, nil
|
||||||
@ -289,8 +288,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
|
|||||||
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max)
|
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
|
func ProcessesWithContext(ctx context.Context) ([]*Process, error) {
|
||||||
@ -331,7 +330,7 @@ func (p *Process) getKProc() (*KinfoProc, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if length != sizeOfKinfoProc {
|
if length != sizeOfKinfoProc {
|
||||||
return nil, err
|
return nil, errors.New("unexpected size of KinfoProc")
|
||||||
}
|
}
|
||||||
|
|
||||||
k, err := parseKinfoProc(buf)
|
k, err := parseKinfoProc(buf)
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Created by cgo -godefs - DO NOT EDIT
|
||||||
// cgo -godefs types_freebsd.go
|
// cgo -godefs types_freebsd.go
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Created by cgo -godefs - DO NOT EDIT
|
||||||
// cgo -godefs types_freebsd.go
|
// cgo -godefs types_freebsd.go
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
// Created by cgo -godefs - DO NOT EDIT
|
// Created by cgo -godefs - DO NOT EDIT
|
||||||
// cgo -godefs types_freebsd.go
|
// cgo -godefs types_freebsd.go
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build freebsd && arm64
|
//go:build freebsd && arm64
|
||||||
|
|
||||||
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -18,9 +18,9 @@ import (
|
|||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
"github.com/shirou/gopsutil/v4/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pageSize = uint64(os.Getpagesize())
|
var pageSize = uint64(os.Getpagesize())
|
||||||
@ -148,26 +148,26 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
return pgid == tpgid, nil
|
return pgid == tpgid, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
err := p.fillFromStatusWithContext(ctx)
|
err := p.fillFromStatusWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []int32{}, err
|
return []uint32{}, err
|
||||||
}
|
}
|
||||||
return p.uids, nil
|
return p.uids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
err := p.fillFromStatusWithContext(ctx)
|
err := p.fillFromStatusWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []int32{}, err
|
return []uint32{}, err
|
||||||
}
|
}
|
||||||
return p.gids, nil
|
return p.gids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
err := p.fillFromStatusWithContext(ctx)
|
err := p.fillFromStatusWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []int32{}, err
|
return []uint32{}, err
|
||||||
}
|
}
|
||||||
return p.groups, nil
|
return p.groups, nil
|
||||||
}
|
}
|
||||||
@ -373,8 +373,8 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
|
|||||||
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
return net.ConnectionsPidWithContext(ctx, "all", p.Pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, max)
|
return net.ConnectionsPidMaxWithContext(ctx, "all", p.Pid, maxConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
|
func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]MemoryMapsStat, error) {
|
||||||
@ -399,7 +399,9 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M
|
|||||||
// function of parsing a block
|
// function of parsing a block
|
||||||
getBlock := func(firstLine []string, block []string) (MemoryMapsStat, error) {
|
getBlock := func(firstLine []string, block []string) (MemoryMapsStat, error) {
|
||||||
m := MemoryMapsStat{}
|
m := MemoryMapsStat{}
|
||||||
m.Path = firstLine[len(firstLine)-1]
|
if len(firstLine) >= 6 {
|
||||||
|
m.Path = strings.Join(firstLine[5:], " ")
|
||||||
|
}
|
||||||
|
|
||||||
for _, line := range block {
|
for _, line := range block {
|
||||||
if strings.Contains(line, "VmFlags") {
|
if strings.Contains(line, "VmFlags") {
|
||||||
@ -727,8 +729,12 @@ func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, e
|
|||||||
case "syscw":
|
case "syscw":
|
||||||
ret.WriteCount = t
|
ret.WriteCount = t
|
||||||
case "read_bytes":
|
case "read_bytes":
|
||||||
ret.ReadBytes = t
|
ret.DiskReadBytes = t
|
||||||
case "write_bytes":
|
case "write_bytes":
|
||||||
|
ret.DiskWriteBytes = t
|
||||||
|
case "rchar":
|
||||||
|
ret.ReadBytes = t
|
||||||
|
case "wchar":
|
||||||
ret.WriteBytes = t
|
ret.WriteBytes = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -866,32 +872,32 @@ func (p *Process) fillFromStatusWithContext(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
p.tgid = int32(pval)
|
p.tgid = int32(pval)
|
||||||
case "Uid":
|
case "Uid":
|
||||||
p.uids = make([]int32, 0, 4)
|
p.uids = make([]uint32, 0, 4)
|
||||||
for _, i := range strings.Split(value, "\t") {
|
for _, i := range strings.Split(value, "\t") {
|
||||||
v, err := strconv.ParseInt(i, 10, 32)
|
v, err := strconv.ParseInt(i, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.uids = append(p.uids, int32(v))
|
p.uids = append(p.uids, uint32(v))
|
||||||
}
|
}
|
||||||
case "Gid":
|
case "Gid":
|
||||||
p.gids = make([]int32, 0, 4)
|
p.gids = make([]uint32, 0, 4)
|
||||||
for _, i := range strings.Split(value, "\t") {
|
for _, i := range strings.Split(value, "\t") {
|
||||||
v, err := strconv.ParseInt(i, 10, 32)
|
v, err := strconv.ParseInt(i, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.gids = append(p.gids, int32(v))
|
p.gids = append(p.gids, uint32(v))
|
||||||
}
|
}
|
||||||
case "Groups":
|
case "Groups":
|
||||||
groups := strings.Fields(value)
|
groups := strings.Fields(value)
|
||||||
p.groups = make([]int32, 0, len(groups))
|
p.groups = make([]uint32, 0, len(groups))
|
||||||
for _, i := range groups {
|
for _, i := range groups {
|
||||||
v, err := strconv.ParseInt(i, 10, 32)
|
v, err := strconv.ParseUint(i, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.groups = append(p.groups, int32(v))
|
p.groups = append(p.groups, uint32(v))
|
||||||
}
|
}
|
||||||
case "Threads":
|
case "Threads":
|
||||||
v, err := strconv.ParseInt(value, 10, 32)
|
v, err := strconv.ParseInt(value, 10, 32)
|
@ -1,5 +1,5 @@
|
|||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package process
|
package process
|
||||||
|
|
||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -14,10 +15,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
cpu "github.com/shirou/gopsutil/v3/cpu"
|
cpu "github.com/shirou/gopsutil/v4/cpu"
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v4/internal/common"
|
||||||
mem "github.com/shirou/gopsutil/v3/mem"
|
mem "github.com/shirou/gopsutil/v4/mem"
|
||||||
net "github.com/shirou/gopsutil/v3/net"
|
net "github.com/shirou/gopsutil/v4/net"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -176,40 +177,40 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
|
|||||||
return strings.IndexByte(string(out), '+') != -1, nil
|
return strings.IndexByte(string(out), '+') != -1, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) UidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) UidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
uids := make([]int32, 0, 3)
|
uids := make([]uint32, 0, 3)
|
||||||
|
|
||||||
uids = append(uids, int32(k.Ruid), int32(k.Uid), int32(k.Svuid))
|
uids = append(uids, uint32(k.Ruid), uint32(k.Uid), uint32(k.Svuid))
|
||||||
|
|
||||||
return uids, nil
|
return uids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GidsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GidsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
gids := make([]int32, 0, 3)
|
gids := make([]uint32, 0, 3)
|
||||||
gids = append(gids, int32(k.Rgid), int32(k.Ngroups), int32(k.Svgid))
|
gids = append(gids, uint32(k.Rgid), uint32(k.Ngroups), uint32(k.Svgid))
|
||||||
|
|
||||||
return gids, nil
|
return gids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) GroupsWithContext(ctx context.Context) ([]int32, error) {
|
func (p *Process) GroupsWithContext(ctx context.Context) ([]uint32, error) {
|
||||||
k, err := p.getKProc()
|
k, err := p.getKProc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
groups := make([]int32, k.Ngroups)
|
groups := make([]uint32, k.Ngroups)
|
||||||
for i := int16(0); i < k.Ngroups; i++ {
|
for i := int16(0); i < k.Ngroups; i++ {
|
||||||
groups[i] = int32(k.Groups[i])
|
groups[i] = uint32(k.Groups[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups, nil
|
return groups, nil
|
||||||
@ -304,7 +305,7 @@ func (p *Process) ConnectionsWithContext(ctx context.Context) ([]net.ConnectionS
|
|||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, max int) ([]net.ConnectionStat, error) {
|
func (p *Process) ConnectionsMaxWithContext(ctx context.Context, maxConn int) ([]net.ConnectionStat, error) {
|
||||||
return nil, common.ErrNotImplementedError
|
return nil, common.ErrNotImplementedError
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +344,7 @@ func (p *Process) getKProc() (*KinfoProc, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if length != sizeOfKinfoProc {
|
if length != sizeOfKinfoProc {
|
||||||
return nil, err
|
return nil, errors.New("unexpected size of KinfoProc")
|
||||||
}
|
}
|
||||||
|
|
||||||
k, err := parseKinfoProc(buf)
|
k, err := parseKinfoProc(buf)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user