https://github.com/martichou/sys_metrics
Cross-platform library to gather stats/information from the host 🦀
https://github.com/martichou/sys_metrics
sys-metrics
Last synced: 2 months ago
JSON representation
Cross-platform library to gather stats/information from the host 🦀
- Host: GitHub
- URL: https://github.com/martichou/sys_metrics
- Owner: Martichou
- License: agpl-3.0
- Created: 2020-11-24T13:01:57.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-01T03:26:52.000Z (5 months ago)
- Last Synced: 2025-03-31T16:10:38.646Z (2 months ago)
- Topics: sys-metrics
- Language: Rust
- Homepage:
- Size: 266 KB
- Stars: 41
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sys_metrics
Gather metrics from the host
[](LICENSE)
[](https://crates.io/crates/sys_metrics)
[](https://docs.rs/sys_metrics)
[](https://github.com/Martichou/sys_metrics/actions)
`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](https://github.com/giampaolo/psutil) or [heim](https://github.com/heim-rs/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`
```toml
[dependencies]
sys_metrics = "0.2"
```
Example of **basic** usage:
```rust
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](https://github.com/speculare-cloud/speculare-client/blob/master/src/harvest/data_harvest.rs).Benchmarks
--------------------------See [BENCHMARKS](https://github.com/Martichou/sys_metrics/blob/master/BENCHMARKS.md) for a comparison of sys_metrics with other crates.
```bash
➜ 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.