Documentation
¶
Overview ¶
Package procstats measures per-process CPU and RSS over a reset-to-snapshot interval using Linux procfs. The filesystem is injectable so parsing and interval behavior can be tested on every development platform.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector owns a baseline and produces interval snapshots. Reset and Snapshot are serialized so a baseline cannot be changed mid-scan.
func New ¶
New creates an idle collector. Call Reset immediately before the measured interval and Snapshot after it.
type Health ¶
type Health struct {
Status Status `json:"status"`
Partial bool `json:"partial"`
Dropped uint64 `json:"dropped"`
Errors []string `json:"errors,omitempty"`
}
Health describes collection failures without making the measured application fail. Errors is bounded; Dropped always contains the full count.
type Option ¶
type Option func(*Collector)
Option configures a Collector.
func WithClockTicks ¶
WithClockTicks sets USER_HZ used to convert process jiffies to seconds. Linux is normally 100; injection avoids a libc dependency and enables tests.
func WithFS ¶
WithFS supplies a procfs-like filesystem. It is primarily intended for deterministic tests and non-Linux development hosts.
func WithPageSize ¶
WithPageSize sets the byte size used for statm resident pages.
func WithProcRoot ¶
WithProcRoot selects a procfs root. The default is /proc.
type Process ¶
type Process struct {
PID int `json:"pid"`
Command string `json:"command"`
CPUPercent float64 `json:"cpuPercent"`
CPUSeconds float64 `json:"cpuSeconds"`
RSSBytes uint64 `json:"rssBytes"`
DeltaJiffies uint64 `json:"deltaJiffies"`
Starttime uint64 `json:"starttime"`
Appeared bool `json:"appeared,omitempty"`
PIDReused bool `json:"pidReused,omitempty"`
}
Process is one process's reset-to-snapshot CPU delta and end-of-interval RSS.
type Snapshot ¶
type Snapshot struct {
StartedAt time.Time `json:"startedAt"`
EndedAt time.Time `json:"endedAt"`
IntervalJiffies uint64 `json:"intervalJiffies"`
CPUs int `json:"cpus"`
TopCPU []Process `json:"topCPU"`
TopRSS []Process `json:"topRSS"`
Health Health `json:"health"`
}
Snapshot is the process report for the current reset-to-snapshot interval. CPU percent follows top: one fully occupied core is 100%.