2 releases

0.1.1 Mar 5, 2021
0.1.0 Mar 4, 2021

#596 in Unix APIs

Download history 737/week @ 2024-07-21 632/week @ 2024-07-28 846/week @ 2024-08-04 802/week @ 2024-08-11 769/week @ 2024-08-18 805/week @ 2024-08-25 854/week @ 2024-09-01 841/week @ 2024-09-08 675/week @ 2024-09-15 629/week @ 2024-09-22 1110/week @ 2024-09-29 1016/week @ 2024-10-06 1024/week @ 2024-10-13 971/week @ 2024-10-20 894/week @ 2024-10-27 885/week @ 2024-11-03

3,872 downloads per month
Used in 2 crates

MIT license

12KB
172 lines

MIT [Latest Version][l0] docs Chat on Miaou

proc-status

basic process information

The data comes from /proc/<pid>/process and is only available on unix-like systems.

This crate aims at keeping very simple. If it doesn't cover your needs, you should probably have a look at the much more complete procfs.

Examples:

Dump memory info about the current process:

let mem = proc_status::mem_usage().unwrap();
println!("Mem usage in bytes: current={}, peak={}", mem.current, mem.peak);

This prints something like

Mem usage in bytes: current=1232896, peak=141430784

Print all the fields of the current process' status:

use proc_status::ProcStatus;

let ps = ProcStatus::read().unwrap();
for entry in ps.entries() {
    let entry = entry.unwrap();
    println!("{} = {:?}", entry.key, entry.value);
}

Get the raw value of specific entries

use proc_status::ProcStatus;

let ps = ProcStatus::read().unwrap();
println!("State: {:?}", ps.value("State").unwrap());
println!("VmPeak in bytes: {:?}", ps.value_KiB("VmPeak").unwrap() * 1024);

Dependencies

~245–700KB
~16K SLoC