Module proc_sys_parser::loadavg
source · Expand description
Read data from /proc/loadavg into the struct ProcLoadavg.
The processor of /proc/loadavg takes the values in the file, and puts them in the struct ProcLoadavg.
The values are the load averages for 1, 5 and 15 minutes, the current number runnable processes slash total number of
processes and the last pid created.
Documentation: https://docs.kernel.org/filesystems/proc.html
Here is an example obtaining the data from /proc/loadavg:
use proc_sys_parser::loadavg;
let proc_loadavg = loadavg::read();
println!("{:#?}", proc_loadavg);Example output:
ProcLoadavg {
load_1: 0.0,
load_5: 0.0,
load_15: 0.0,
current_runnable: 0,
total: 0,
last_pid: 12345,
}
(edited for readability)
If you want to change the path and/or file that is read for ProcLoadavg, which is /proc/loadavg
by default, use:
use proc_sys_parser::{meminfo, meminfo::Builder};
let proc_loadavg = Builder::new().path("/myproc").read();Structs§
- Builder pattern for
ProcLoadavg - Struct for holding
/proc/loadavgstatistics
Functions§
- The main function for building a [
ProcMemInfo] struct with current data. This uses the Builder pattern, which allows settings such as the filename to specified.