procinfo

package
v0.14.5-beta.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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