procinfo

package
v0.4.79 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("procinfo: process not found")

ErrNotFound is returned by GetProcInfo when the requested pid does not exist.

View Source
var LinuxStatStatus = map[string]string{
	"R": "running",
	"S": "sleeping",
	"D": "disk-wait",
	"Z": "zombie",
	"T": "stopped",
	"t": "tracing-stop",
	"W": "paging",
	"X": "dead",
	"x": "dead",
	"K": "wakekill",
	"P": "parked",
	"I": "idle",
}

LinuxStatStatus maps the single-character state from /proc/[pid]/stat to a human-readable name.

Functions

func MakeGlobalSnapshot

func MakeGlobalSnapshot() (any, error)

Types

type ProcInfo

type ProcInfo struct {
	Pid        int32
	Ppid       int32
	Command    string
	Status     string
	CpuUser    float64 // cumulative user CPU seconds; -1 if unavailable
	CpuSys     float64 // cumulative system CPU seconds; -1 if unavailable
	VmRSS      int64   // resident set size in bytes; -1 if unavailable
	Uid        uint32
	NumThreads int32 // -1 if unavailable
}

ProcInfo holds per-process information read from the OS. CpuUser and CpuSys are cumulative CPU seconds since process start; callers should diff two samples over a known interval to derive a rate. CpuUser, CpuSys, and VmRSS are set to -1 when the data is unavailable (e.g. permission denied reading another user's process).

func GetProcInfo

func GetProcInfo(_ context.Context, _ any, pid int32) (*ProcInfo, error)

GetProcInfo reads process information for the given pid from /proc. It reads /proc/[pid]/stat for most fields and /proc/[pid]/status for the UID.

Jump to

Keyboard shortcuts

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