Module proc_sys_parser::meminfo
source · Expand description
Read data from /proc/meminfo into the struct ProcMemInfo.
The processor of /proc/meminfo takes the values for the memory areas specified, and puts them in the
struct ProcMemInfo. The values are in kilobytes (kB), just like the values in the original /proc/meminfo
file.
Here is an example obtaining the data from /proc/meminfo:
use proc_sys_parser::{meminfo, meminfo::ProcMemInfo};
let proc_meminfo = meminfo::read();
println!("{:#?}", proc_meminfo);Example output:
ProcMemInfo {
memtotal: 3997876,
memfree: 2415136,
memavailable: 3654096,
buffers: 37492,
cached: 1305568,
swapcached: 0,
active: 880772,
inactive: 549432,
active_anon: 86968,
inactive_anon: 5196,
active_file: 793804,
inactive_file: 544236,
unevictable: 4000,
mlocked: 0,
swaptotal: 0,
swapfree: 0,
zswap: 0,
zswapped: 0,
dirty: 0,
writeback: 0,
anonpages: 91144,
mapped: 140948,
shmem: 5020,
kreclaimable: 56680,
slab: 93916,
sreclaimable: 56680,
sunreclaim: 37236,
kernelstack: 3256,
shadowcallstack: 828,
pagetables: 2884,
secpagetables: 0,
nfs_unstable: 0,
bounce: 0,
writebacktmp: 0,
commitlimit: 1998936,
committed_as: 944240,
vmalloctotal: 133141626880,
vmallocused: 14124,
vmallocchunk: 0,
percpu: 2280,
hardwarecorrupted: 0,
anonhugepages: 4096,
shmemhugepages: 0,
shmempmdmapped: 0,
filehugepages: 0,
filepmdmapped: 0,
cmatotal: 32768,
cmafree: 31232,
hugepages_total: 0,
hugepages_free: 0,
hugepages_rsvd: 0,
hugepages_surp: 0,
hugepagesize: 2048,
hugetlb: 0
}
(edited for readability)
If you want to change the path and/or file that is read for ProcMemInfo, which is /proc/meminfo
by default, use:
use proc_sys_parser::{meminfo, meminfo::{ProcMemInfo, Builder}};
let proc_meminfo = Builder::new().file_name("/myproc/meminfo").read();Structs
- Builder pattern for
ProcMemInfo - Struct for holding
/proc/meminfostatistics
Functions
- The main function for building a
ProcMemInfostruct with current data. This uses the Builder pattern, which allows settings such as the filename to specified.