psutil

package
v1.34.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockDiskUsage

type MockDiskUsage struct {
	*mock.Mock
}

MockDiskUsage is a mock implementation for disk usage operations.

func (*MockDiskUsage) OSGetenv

func (m *MockDiskUsage) OSGetenv(key string) string

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

func (*MockDiskUsage) OSStat

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

OSStat returns the FileInfo structure describing the named file.

func (*MockDiskUsage) PSDiskUsage

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

PSDiskUsage returns a file system usage for the specified path.

func (*MockDiskUsage) Partitions

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

Partitions returns the disk partition statistics.

type MockPS

type MockPS struct {
	mock.Mock
	PSDiskDeps
}

MockPS is a mock implementation of the PS interface for testing purposes.

func (*MockPS) CPUTimes

func (m *MockPS) CPUTimes(_, _ bool) ([]cpu.TimesStat, error)

CPUTimes returns the CPU times statistics.

func (*MockPS) DiskIO

func (m *MockPS) DiskIO(_ []string) (map[string]disk.IOCountersStat, error)

DiskIO returns the disk I/O statistics.

func (*MockPS) DiskUsage

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

DiskUsage returns the disk usage statistics.

func (*MockPS) NetConnections

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

NetConnections returns a list of network connections opened.

func (*MockPS) NetConntrack

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

NetConntrack returns more detailed info about the conntrack table.

func (*MockPS) NetIO

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

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

func (*MockPS) NetProto

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

NetProto returns network statistics for the entire system.

func (*MockPS) SwapStat

func (m *MockPS) SwapStat() (*mem.SwapMemoryStat, error)

SwapStat returns the swap memory statistics.

func (*MockPS) VMStat

func (m *MockPS) VMStat() (*mem.VirtualMemoryStat, error)

VMStat returns the virtual memory statistics.

type MockPSDisk

type MockPSDisk struct {
	*SystemPS
	*mock.Mock
}

MockPSDisk is a mock implementation of the PSDiskDeps interface for testing purposes.

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.

Jump to

Keyboard shortcuts

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