#cpu-memory #memory #cpu #cpu-gpu #monitor #gpu #nvidia

machine-info

CPU, GPU and memory monitor. Use it to track resources usage

9 stable releases

1.0.9 Oct 4, 2022
1.0.6 Sep 27, 2022
1.0.1 Sep 3, 2022
1.0.0 Sep 2, 2022

#545 in Operating systems

Download history 63/week @ 2024-07-21 66/week @ 2024-07-28 89/week @ 2024-08-04 102/week @ 2024-08-11 70/week @ 2024-08-18 75/week @ 2024-08-25 63/week @ 2024-09-01 72/week @ 2024-09-08 74/week @ 2024-09-15 84/week @ 2024-09-22 41/week @ 2024-09-29 144/week @ 2024-10-06 85/week @ 2024-10-13 38/week @ 2024-10-20 29/week @ 2024-10-27 32/week @ 2024-11-03

188 downloads per month
Used in cutefetch

Custom license

26KB
420 lines

Machine Info

Get information about your machine and monitor the resources usage.

Crates.io Apache 2 licensed

Website | API Docs

Overview

There are many crates to get information about your system. We actually are using some of them but this crate adds a feature to constantly monitor the system without a big overhead.

You can probe your system for CPU or memory usage once per second and your machine performance will not be affected at all. Other crates consumed like 7-10% of CPU which is not acceptable. But to be fair, these other crates are doing many other things apart from getting the cpu/memory usage.

This crate focus only on this, nothing else. Limited but lightweight. If you want a full featured crate better use other one.

Example

Just a simple monitoring

[dependencies]
machine-info = "1.0.6"

Put this in your main.rs:

use machine_info::Machine;
use std::{thread, time};


fn main() {
    let mut m = Machine::new();
    // Please use a real PIDs!
    m.track_process(132801).unwrap();
    m.track_process(32930).unwrap();
    
    for _ in 1..100 {
        let processes = m.processes_status();
        let system = m.system_status();
        let graphics = m.graphics_status();
        println!("{:?} {:?} {:?}", processes, system, graphics);
        
        thread::sleep(time::Duration::from_millis(1000));
    }
}

Features

You can compile the library with v4l support for cameras scanning.

[dependencies]
machine-info = { version = "1.0.6", features = ["v4l"] }

Your probably need to install libclang-dev package

sudo apt-get install libclang-dev

This crate is based on other awesome libraries like:

  • sysinfo: sysinfo is a crate used to get a system’s information.
  • nvml-wrapper: A safe and ergonomic Rust wrapper for the NVIDIA Management Library (NVML)
  • libv4l-rs: Safe video4linux (v4l) bindings

License

This project is licensed under the Apache 2 license.

Dependencies

~2.5–3.5MB
~72K SLoC