memory

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCmdline

func GetCmdline(ctx context.Context, pid int) []string

The GetCmdline helper returns the command line for a pid. If the pid does not exist or we don't have access to read /proc/<pid>/cmdline, then it returns the empty string.

Types

type MemoryUsage

type MemoryUsage struct {
	// contains filtered or unexported fields
}

The MemoryUsage struct to holds memory usage and memory limit information about a cgroup.

func GetMemoryUsage

func GetMemoryUsage(ctx context.Context) *MemoryUsage

The GetMemoryUsage function returns MemoryUsage info for the entire cgroup.

func (*MemoryUsage) PercentUsed

func (m *MemoryUsage) PercentUsed() int

The MemoryUsage.PercentUsed method returns memory usage as a percentage of memory limit.

func (*MemoryUsage) Refresh

func (m *MemoryUsage) Refresh(ctx context.Context)

The MemoryUsage.Refresh method updates memory usage information.

func (*MemoryUsage) ShortString

func (m *MemoryUsage) ShortString() string

func (*MemoryUsage) String

func (m *MemoryUsage) String() string

Pretty print a summary of memory usage suitable for logging.

func (*MemoryUsage) Watch

func (usage *MemoryUsage) Watch(ctx context.Context)

The Watch method will check memory usage every 10 seconds and log it if it jumps more than 10Gi up or down. Additionally if memory usage exceeds 50% of the cgroup limit, it will log usage every minute. Usage is also unconditionally logged before returning. This function only returns if the context is canceled.

type ProcessUsage

type ProcessUsage struct {
	Pid     int
	Cmdline []string
	Usage   memory

	// This is zero if the process is still running. If the process has exited, this counts how many
	// refreshes have happened. We GC after 10 refreshes.
	RefreshesSinceExit int
}

The ProcessUsage struct holds per process memory usage information.

func (ProcessUsage) String

func (pu ProcessUsage) String() string

Pretty print a summary of process memory usage.

Jump to

Keyboard shortcuts

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