proc

package
v0.0.0-...-d288915 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("Process not found")

ErrNotFound is returned if the process is not found

Functions

func ParseMemInfoMemTotal

func ParseMemInfoMemTotal(reader io.Reader) (int, error)

/proc/meminfo

func ParseProcMounts

func ParseProcMounts(data []byte) ([]string, error)

/proc/mounts Currently just gets the "mntonname" since that is all we need.

Types

type KernelVersion

type KernelVersion struct {
	Major int
	Minor int
}

func ParseOSRelease

func ParseOSRelease(data []byte) (KernelVersion, error)

/proc/sys/kernel/osrelease

func (KernelVersion) String

func (k KernelVersion) String() string

type ListAllOpt

type ListAllOpt func(*listAllConf)

ListAllOpt are functional options for listing processes

func WithProcMount

func WithProcMount(mountPoint string) ListAllOpt

WithProcMount sets the mount point for proc

type Process

type Process struct {
	// Pid is the process ID.
	Pid int
	// contains filtered or unexported fields
}

Process represents a process from /proc

func ListAll

func ListAll(opts ...ListAllOpt) ([]*Process, error)

ListAll lists all the processes under the proc mount

func (*Process) Stat

func (proc *Process) Stat() (*ProcessStat, error)

Stat returns the contents of /proc/pid/stat

type ProcessStat

type ProcessStat struct {
	Pid   int
	Comm  string
	State string
	PPid  int
}

ProcessStat contains (some of) the contents of /proc/pid/stat

type ProcessTree

type ProcessTree map[int]*ProcessTreeProc

ProcessTree organizes the processes in a tree you can follow each pid, and each of the processes that have that pid as a parent will be listed as a child

func Tree

func Tree(opts ...ListAllOpt) (ProcessTree, error)

Tree gets the process tree

type ProcessTreeProc

type ProcessTreeProc struct {
	Process
	Children []*ProcessTreeProc
}

ProcessTreeProc is a Process with Children

Jump to

Keyboard shortcuts

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