presutaoru (ぷれすたおる)
A linux Pressure Stall Information (PSI) file descriptor monitor library for Rust.
Example
use ;
use Duration;
let psi_fd = default
.entry
.stall_type
.stall_amount
.time_window
.build
.unwrap;
Addionally, to monitor PSI events, enable the monitor feature.
//! [dependencies]
//! presutaoru = { version = "0.1", features = ["monitor"] }
let mut monitor = new;
monitor.add_fd;
Running the monitor
When using std::thread:
// same as above
//! [dependencies]
//! presutaoru = { version = "0.1", features = ["monitor", "thread"] }
let mut thread = monitor.into_thread.unwrap;
thread.start.unwrap;
while let Ok = thread.recv
Or register the file desc to tokio's reactor:
// same as above
//! [dependencies]
//! presutaoru = { version = "0.1", features = ["monitor", "tokio"] }
use PsiTokioReactor;
let mut job = monitor.into_tokio_reactor.unwrap;
job.start.unwrap;
while let Ok = job.recv.await
All file descriptors will be closed when the monitor or its thread / job are dropped.
// ...
drop; // all fds are closed here
// ...
// in the thread example
drop; // all fds are closed here
// ...
// in the tokio example
drop; // all fds are closed here
Features
monitor: Enable PSI event monitoring functionality.thread: Enable monitoring using std::thread.tokio: Enable monitoring using tokio's reactor.
All features are disabled by default.
thread and tokio features require monitor feature to be enabled.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.