psutil

package
v1.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PS

type PS interface {
	// CPUTimes returns the CPU times statistics.
	CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error)
	// DiskUsage returns the disk usage statistics.
	DiskUsage(mountPointFilter []string, mountOptsExclude []string, fstypeExclude []string) ([]*disk.UsageStat, []*disk.PartitionStat, error)
	// NetIO returns network I/O statistics for every network interface installed on the system.
	NetIO() ([]net.IOCountersStat, error)
	// NetProto returns network statistics for the entire system.
	NetProto() ([]net.ProtoCountersStat, error)
	// DiskIO returns the disk I/O statistics.
	DiskIO(names []string) (map[string]disk.IOCountersStat, error)
	// VMStat returns the virtual memory statistics.
	VMStat() (*mem.VirtualMemoryStat, error)
	// SwapStat returns the swap memory statistics.
	SwapStat() (*mem.SwapMemoryStat, error)
	// NetConnections returns a list of network connections opened.
	NetConnections() ([]net.ConnectionStat, error)
	// NetConntrack returns more detailed info about the conntrack table.
	NetConntrack(perCPU bool) ([]net.ConntrackStat, error)
}

PS is an interface that defines methods for gathering system statistics.

type PSDiskDeps

type PSDiskDeps interface {
	// Partitions returns the disk partition statistics.
	Partitions(all bool) ([]disk.PartitionStat, error)
	// OSGetenv returns the value of the environment variable named by the key.
	OSGetenv(key string) string
	// OSStat returns the FileInfo structure describing the named file.
	OSStat(name string) (os.FileInfo, error)
	// PSDiskUsage returns a file system usage for the specified path.
	PSDiskUsage(path string) (*disk.UsageStat, error)
}

PSDiskDeps is an interface that defines methods for gathering disk statistics.

type SystemPS

type SystemPS struct {
	PSDiskDeps
	Log telegraf.Logger `toml:"-"`
}

SystemPS is a struct that implements the PS interface.

func NewSystemPS

func NewSystemPS() *SystemPS

NewSystemPS creates a new instance of SystemPS.

func (*SystemPS) CPUTimes

func (*SystemPS) CPUTimes(perCPU, totalCPU bool) ([]cpu.TimesStat, error)

CPUTimes returns the CPU times statistics.

func (*SystemPS) DiskIO

func (*SystemPS) DiskIO(names []string) (map[string]disk.IOCountersStat, error)

DiskIO returns the disk I/O statistics.

func (*SystemPS) DiskUsage

func (s *SystemPS) DiskUsage(mountPointFilter, mountOptsExclude, fstypeExclude []string) ([]*disk.UsageStat, []*disk.PartitionStat, error)

DiskUsage returns the disk usage statistics.

func (*SystemPS) NetConnections

func (*SystemPS) NetConnections() ([]net.ConnectionStat, error)

NetConnections returns a list of network connections opened.

func (*SystemPS) NetConntrack

func (*SystemPS) NetConntrack(perCPU bool) ([]net.ConntrackStat, error)

NetConntrack returns more detailed info about the conntrack table.

func (*SystemPS) NetIO

func (*SystemPS) NetIO() ([]net.IOCountersStat, error)

NetIO returns network I/O statistics for every network interface installed on the system.

func (*SystemPS) NetProto

func (*SystemPS) NetProto() ([]net.ProtoCountersStat, error)

NetProto returns network statistics for the entire system.

func (*SystemPS) SwapStat

func (*SystemPS) SwapStat() (*mem.SwapMemoryStat, error)

SwapStat returns the swap memory statistics.

func (*SystemPS) VMStat

func (*SystemPS) VMStat() (*mem.VirtualMemoryStat, error)

VMStat returns the virtual memory statistics.

type SystemPSDisk

type SystemPSDisk struct{}

SystemPSDisk is a struct that implements the PSDiskDeps interface.

func (*SystemPSDisk) OSGetenv

func (*SystemPSDisk) OSGetenv(key string) string

OSGetenv returns the value of the environment variable named by the key.

func (*SystemPSDisk) OSStat

func (*SystemPSDisk) OSStat(name string) (os.FileInfo, error)

OSStat returns the FileInfo structure describing the named file.

func (*SystemPSDisk) PSDiskUsage

func (*SystemPSDisk) PSDiskUsage(path string) (*disk.UsageStat, error)

PSDiskUsage returns a file system usage for the specified path.

func (*SystemPSDisk) Partitions

func (*SystemPSDisk) Partitions(all bool) ([]disk.PartitionStat, error)

Partitions returns the disk partition statistics.

Directories

Path Synopsis
Package psutiltest provides mock implementations of the psutil interfaces for testing.
Package psutiltest provides mock implementations of the psutil interfaces for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL