#linux #client #delay-accounting #taskstats

bin+lib linux-taskstats

Rust interface to Linux taskstats

11 unstable releases (5 breaking)

0.7.0 Aug 15, 2024
0.6.0 Apr 4, 2024
0.5.0 Mar 1, 2024
0.4.0 Jan 21, 2023
0.1.3 May 27, 2020

#448 in #linux

Download history 25/week @ 2024-12-11 2/week @ 2024-12-18 20/week @ 2024-12-25 7/week @ 2025-01-01 17/week @ 2025-01-08 8/week @ 2025-01-15 42/week @ 2025-01-22 29/week @ 2025-01-29 27/week @ 2025-02-05 46/week @ 2025-02-12 43/week @ 2025-02-19 87/week @ 2025-02-26 63/week @ 2025-03-05 9/week @ 2025-03-12 28/week @ 2025-03-19 10/week @ 2025-03-26

120 downloads per month

MIT license

50KB
1K SLoC

linux-taskstats-rs

Rust interface to Linux's taskstats.

This crate provides access to taskstats which is known as a way to access task's "delay" information a.k.a Delay Accounting.

Usage

use linux_taskstats::{self, Delays, Client};

fn get_thread_delays(pid: u32) -> Result<Delays, linux_taskstats::Error> {
    let client = Client::open()?;
    let ts = client.pid_stats(pid)?;
    Ok(ts.delays)
}

fn get_process_delays(pid: u32) -> Result<Delays, linux_taskstats::Error> {
    let client = Client::open()?;
    let ts = client.tgid_stats(pid)?;
    Ok(ts.delays)
}

How to build

cargo test
cargo build

Or on platform other than linux:

./docker-build/build-docker-image.sh # Just once, creates a image `taskstats-build:latest`
./docker-build/build.sh
# The outputs will be created under docker-build/target

License

MIT

Dependencies

~3–14MB
~162K SLoC