taskstats

Crates.iotaskstats
lib.rstaskstats
version0.1.1
sourcesrc
created_at2020-05-17 06:09:08.01194
updated_at2020-05-17 07:06:26.83601
descriptionhigh-level encapsulation of Linux's per-task statistics interface
homepage
repository
max_upload_size
id242567
size54,452
Xidorn Quan (upsuper)

documentation

README

taskstats-rs

This crate provides a high-level encapsulation of Linux's per-task statistics interface.

Currently only limited information is exposed in Taskstats struct, but new field can be easily added for future version. If there are any other fields in taskstats struct useful to you, feel free to submit PR to add them.

Examples

Query aggregated taskstats of a task:

let mut conn = TaskstatsConnection::new()?;
let stats = conn.get_pid_stats(1)?;
// ...

Listen to taskstats of exited tasks:

let conn = TaskstatsConnection::new()?;
let cpu_mask = CString::new("0-7\0".to_owned()).unwrap().into_boxed_c_str();
let mut listener = TaskstatsListener::register(conn, cpu_mask)?;
loop {
    let (pid, stats) = listener.get_next()?;
    // ...
}

Development

raw.rs files in src, src/netlink, and src/genetlink are generated from corresponding headers, then manually adjusted to fit the needs.

Note

This crate only exposes stats for pid / task, but not tgid / process, because the kernel doesn't really pass much useful information for tgid. It is recommended that you rely on pid stats and aggregate for process manually.

Commit count: 0

cargo fmt