#meter #monitoring #linux #resources #cpu-memory #io-write

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

#1566 in Filesystem

Download history 58/week @ 2024-03-12 55/week @ 2024-03-19 43/week @ 2024-03-26 62/week @ 2024-04-02 29/week @ 2024-04-09 36/week @ 2024-04-16 32/week @ 2024-04-23 24/week @ 2024-04-30 23/week @ 2024-05-07 50/week @ 2024-05-14 50/week @ 2024-05-21 56/week @ 2024-05-28 47/week @ 2024-06-04 40/week @ 2024-06-11 59/week @ 2024-06-18 29/week @ 2024-06-25

186 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
~26K SLoC