#meter #monitoring #linux

self-meter

A tiny library to measure resource usage of the process it's used in

8 releases (4 breaking)

Uses old Rust 2015

0.6.0 May 24, 2017
0.5.0 Apr 7, 2017
0.4.4 Apr 3, 2017
0.4.3 Mar 30, 2017
0.1.0 Sep 27, 2016

#1342 in Filesystem

Download history 26/week @ 2023-11-20 22/week @ 2023-11-27 80/week @ 2023-12-04 63/week @ 2023-12-11 23/week @ 2023-12-18 13/week @ 2023-12-25 36/week @ 2024-01-01 49/week @ 2024-01-08 21/week @ 2024-01-15 65/week @ 2024-01-22 35/week @ 2024-01-29 13/week @ 2024-02-05 36/week @ 2024-02-12 24/week @ 2024-02-19 73/week @ 2024-02-26 27/week @ 2024-03-04

161 downloads per month
Used in 5 crates (3 directly)

MIT/Apache

31KB
652 lines

Self-Meter

Status:beta
Documentation:https://docs.rs/self-meter/

A tiny library to measure resource usage of the process it's used in. Currently it measures:

  • Memory Usage
  • CPU Usage with breakdown by each thread
  • Disk Usage

More metrics might be added later. Currently, library supports only linux, but pull requests for other platforms are welcome.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

A tiny library to measure resource usage of the process it's used in. Currently it measures:

  • Memory Usage
  • CPU Usage with breakdown by each thread
  • Disk Usage

More metrics might be added later. Currently, library supports only linux, but pull requests for other platforms are welcome.

Example



fn main() {
   let mut meter = self_meter::Meter::new(Duration::new(1, 0)).unwrap();
   meter.track_current_thread("main");
   loop {
       meter.scan()
           .map_err(|e| writeln!(&mut stderr(), "Scan error: {}", e)).ok();
       println!("Report: {:#?}", meter.report());
       println!("Threads: {:#?}",
           meter.thread_report().map(|x| x.collect::<BTreeMap<_,_>>()));
       // Put your task here
       // ...
       //
       sleep(Duration::new(1, 0));
   }
}

Dependencies

~0.5–1.1MB
~27K SLoC