Canop / proc-status

a crate giving you information about a process, for example yours

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIT Latest Version 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 bigger 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);

About

a crate giving you information about a process, for example yours


Languages

Language:Rust 100.0%