Skip to main content

Module cpu

Module cpu 

Source

Structsยง

CpuCollector
Snapshot ๐Ÿ”’

Functionsยง

aggregate_util_cores ๐Ÿ”’
Aggregate utilization expressed as fractional cores in use (0.0..n_cores). Not clamped: kernel rounding can produce values very slightly above n_cores.
core_util_pct ๐Ÿ”’
Per-core utilization percentage (0.0โ€“100.0, clamped).
cpu_idle ๐Ÿ”’
cpu_total ๐Ÿ”’
process_tree_io ๐Ÿ”’
Per-process cumulative disk I/O bytes from /proc/pid/io. Returns { pid -> (read_bytes, write_bytes) }. PIDs whose /proc/pid/io is unreadable (e.g. different UID without ptrace) are silently omitted โ€“ the delta for those PIDs will be 0.
process_tree_rss_mib ๐Ÿ”’
Sum of VmRSS (kB) across all given PIDs, converted to MiB. Processes that have exited or whose /proc/pid/status is unreadable are skipped.
process_tree_ticks ๐Ÿ”’
Returns a map of { pid to (utime, stime) } for every process in the tree rooted at root_pid (root included). Processes that have already exited are silently skipped: this is a TOCTOU race we accept.
util_pct_from_ticks ๐Ÿ”’
Pure math: percentage of non-idle ticks between two snapshots (0.0โ€“100.0 before any clamping). Takes raw pre-computed totals/idles so it can be unit-tested without constructing a CpuTime (which has private fields).

Type Aliasesยง

Result ๐Ÿ”’