Documentation
¶
Overview ¶
Package procstat reads the machine's process table and what each process costs — CPU and resident memory — on macOS, Linux and Windows.
It only reads. Nothing here signals, opens or writes to another process; rule 7 forbids signalling a process Caprock did not start, and reading the figures a process manager shows is not that.
The table comes from one call where the OS has one (sysctl kern.proc.all on macOS) and from gopsutil elsewhere; per-process CPU time and resident size come from gopsutil on every OS. CPU is a percentage of one core between two samples, so a process tree using three cores reads 300%.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmdline ¶
Cmdline is a process's argument vector; nil when it cannot be read (another user's process, or one that has exited).
Types ¶
type Proc ¶
type Proc struct {
PID int32
PPID int32
// Name is the OS's short name for the process (macOS truncates it to 16
// bytes); Label is better for showing a person.
Name string
// UID is the owner's user id, -1 where the table does not say (Windows).
UID int64
// StartMs is when the process started, unix ms, 0 when unknown. A pid
// with a different start is a different process.
StartMs int64
}
Proc is one row of the process table.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler turns cumulative CPU time into a rate. It is not safe for concurrent use.
type Usage ¶
type Usage struct {
// CPUPct is percent of one core since the previous sample of the same
// process; Warm is false on the first sample, when there is nothing to
// compare with and CPUPct is 0.
CPUPct float64
Warm bool
// MemBytes is the process's own memory (ownMemory), not its RSS.
MemBytes uint64
}
Usage is one process's cost.