pub struct ProcessSnapshot {
pub timestamp: u64,
pub processes: Vec<ProcessInfo>,
pub summary: ProcessSummary,
}Expand description
Process list snapshot at a point in time.
Contains the raw process list, a computed summary, and a timestamp.
Fields§
§timestamp: u64Unix timestamp (seconds) when the snapshot was taken.
processes: Vec<ProcessInfo>Individual process records parsed from ps -eo.
summary: ProcessSummaryAggregated summary statistics.
Implementations§
Source§impl ProcessSnapshot
impl ProcessSnapshot
Sourcepub fn capture() -> Self
pub fn capture() -> Self
Captures a full process snapshot via ps with explicit format.
Results are cached for 30 seconds to avoid re-parsing on repeated calls within the same execution window.
Sourcepub fn zombies(&self) -> Vec<&ProcessInfo>
pub fn zombies(&self) -> Vec<&ProcessInfo>
Returns all zombie processes with their PID, command, and PPID.
Zombies are defunct child processes whose parent has not yet called
waitpid(2). They consume no resources but each occupies a PID slot.
Sourcepub fn clear_cache()
pub fn clear_cache()
Clears the process snapshot cache.
Use before capturing an after-kill snapshot to ensure fresh data.
Sourcepub fn top_by_cpu(&self, n: usize) -> Vec<&ProcessInfo>
pub fn top_by_cpu(&self, n: usize) -> Vec<&ProcessInfo>
Returns the top n processes by CPU usage.
Sourcepub fn top_by_mem(&self, n: usize) -> Vec<&ProcessInfo>
pub fn top_by_mem(&self, n: usize) -> Vec<&ProcessInfo>
Returns the top n processes by memory usage.
Sourcepub fn print_report(&self)
pub fn print_report(&self)
Prints a human-readable process report to stdout.
Trait Implementations§
Source§impl Clone for ProcessSnapshot
impl Clone for ProcessSnapshot
Source§fn clone(&self) -> ProcessSnapshot
fn clone(&self) -> ProcessSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more