76 releases

0.9.5 Sep 8, 2019
0.9.2 Aug 29, 2019
0.9.1 Jul 26, 2019
0.8.2 Mar 3, 2019
0.0.2 Jul 25, 2015

#3 in Unix APIs

Download history 1566/week @ 2019-06-26 1281/week @ 2019-07-03 1378/week @ 2019-07-10 1036/week @ 2019-07-17 1184/week @ 2019-07-24 1259/week @ 2019-07-31 1433/week @ 2019-08-07 1561/week @ 2019-08-14 4458/week @ 2019-08-21 2640/week @ 2019-08-28 1966/week @ 2019-09-04 1910/week @ 2019-09-11 2712/week @ 2019-09-18 2965/week @ 2019-09-25 5738/week @ 2019-10-02

7,110 downloads per month
Used in 14 crates (13 directly)

MIT license

215KB
5K SLoC

sysinfo Build status

A system handler to interact with processes.

Support the following platforms:

  • Linux
  • Raspberry
  • Mac OSX
  • Windows

It also compiles for Android but never been tested on it.

Running on Raspberry

It'll be difficult to build on Raspberry. A good way-around is to be build on Linux before sending it to your Raspberry:

rustup target add armv7-unknown-linux-gnueabihf
cargo build --target=armv7-unknown-linux-gnueabihf

Code example

You have an example into the examples folder. Just run cargo run inside the examples folder to start it. Otherwise, here is a little code sample:

extern crate sysinfo;

use sysinfo::{NetworkExt, System, SystemExt};

let mut sys = System::new();

// We display the disks:
println!("=> disk list:");
for disk in sys.get_disks() {
    println!("{:?}", disk);
}

// Network data:
println!("input data : {} B", sys.get_network().get_income());
println!("output data: {} B", sys.get_network().get_outcome());

// Components temperature:
for component in sys.get_components_list() {
    println!("{:?}", component);
}

// Memory information:
println!("total memory: {} kB", sys.get_total_memory());
println!("used memory : {} kB", sys.get_used_memory());
println!("total swap  : {} kB", sys.get_total_swap());
println!("used swap   : {} kB", sys.get_used_swap());

// Number of processors
println!("NB processors: {}", sys.get_processor_list().len());

// To refresh all system information:
sys.refresh_all();

C interface

It's possible to use this crate directly from C. Take a look at the Makefile and at the examples/src/simple.c file.

To build the C example, just run:

> make
> ./simple
# If needed:
> LD_LIBRARY_PATH=target/release/ ./simple

Donations

If you appreciate my work and want to support me, you can do it here:

Become a patron

Dependencies

~1MB
~24K SLoC