#metrics #system-info #stats #heim #psutil #api-bindings

bin+lib sys_metrics

Cross-platform library to gather stats/information from the host

7 releases

0.2.7 Mar 24, 2024
0.2.6 Jun 12, 2022
0.2.5 Dec 18, 2021
0.2.4 Aug 11, 2021
0.1.40 Nov 28, 2020

#118 in Operating systems

Download history 127/week @ 2024-07-24 289/week @ 2024-07-31 347/week @ 2024-08-07 220/week @ 2024-08-14 253/week @ 2024-08-21 200/week @ 2024-08-28 156/week @ 2024-09-04 113/week @ 2024-09-11 131/week @ 2024-09-18 192/week @ 2024-09-25 239/week @ 2024-10-02 114/week @ 2024-10-09 118/week @ 2024-10-16 150/week @ 2024-10-23 197/week @ 2024-10-30 129/week @ 2024-11-06

605 downloads per month
Used in 2 crates

AGPL-3.0

86KB
2K SLoC

sys_metrics

Gather metrics from the host

AGPL License crates.io Docs.rs CI

sys_metrics is a WIP project intended to give an alternative to others tools which can be slower or provide too many useless informations. It will try to have at least the same functionality as psutil or heim.

It's a synchronous library which try to be freaking fast (maybe even the fastest) and as dependency-free as possible.

WIP Notes

sys_metrics in it's WIP stage will only support Linux and macOS. The structure is subject to change from version to version. If you have a comment about it or anything else feel free to open an issue.

Usage

Add the dependency to your Cargo.toml

[dependencies]
sys_metrics = "0.2"

Example of basic usage:

use sys_metrics::{cpu::*};

// This is just a very basic example of the CPU part.
// Check the doc, this crate can do much more.
fn main() {
    let cpufreq = get_cpufreq().unwrap();
    println!("CPU Speed: {:13}MHz\n", cpufreq as u64);

    let cpu_logical = get_logical_count().unwrap();
    let cpu_physical = get_physical_count().unwrap();

    println!("CPU Core: {:12}\nLogical processors: {}", cpu_physical, cpu_logical);

    let loadavg = get_loadavg().unwrap();
    println!("Load average: {:10} {} {}", loadavg.one, loadavg.five, loadavg.fifteen);
}

For a more complex example, check this crate in use here: speculare-client/src/harvest/data_harvest.rs.

Benchmarks

See BENCHMARKS for a comparison of sys_metrics with other crates.

 cargo bench

Supported targets

Target test
x86_64-apple-darwin
x86_64-unknown-linux-gnu

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Dependencies

~0.4–1.2MB
~26K SLoC