#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

#1273 in Filesystem

Download history 24/week @ 2024-07-20 55/week @ 2024-07-27 75/week @ 2024-08-03 26/week @ 2024-08-10 32/week @ 2024-08-17 32/week @ 2024-08-24 26/week @ 2024-08-31 23/week @ 2024-09-07 15/week @ 2024-09-14 36/week @ 2024-09-21 55/week @ 2024-09-28 21/week @ 2024-10-05 65/week @ 2024-10-12 19/week @ 2024-10-19 30/week @ 2024-10-26 77/week @ 2024-11-02

191 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.4–1MB
~25K SLoC