Module proc_sys_parser::vmstat
source · Expand description
Read data from /proc/vmstat into the struct ProcVmStat.
The processor of /proc/vmstat takes the values for the memory areas specified, and puts them in the
struct ProcVmStat. The values are in kilobytes (kB), just like the values in the original /proc/vmstat
file.
The file /proc/vmstat has no absolute documentation.
Here is an example obtaining the data from /proc/vmstat:
use proc_sys_parser::{vmstat, vmstat::ProcVmStat};
let proc_vmstat = vmstat::read();
println!("{:#?}", proc_vmstat);Example output:
ProcVmStat {
nr_free_pages: 778263,
nr_zone_inactive_anon: 212,
nr_zone_active_anon: 21214,
nr_zone_inactive_file: 86210,
nr_zone_active_file: 85676,
nr_zone_unevictable: 0,
nr_zone_write_pending: 1,
nr_mlock: 0,
nr_bounce: 0,
nr_zspages: 0,
nr_free_cma: 7808,
numa_hit: 40773813,
numa_miss: 0,
numa_foreign: 0,
numa_interleave: 1212,
numa_local: 40773813,
numa_other: 0,
nr_inactive_anon: 212,
nr_active_anon: 21214,
nr_inactive_file: 86210,
nr_active_file: 85676,
nr_unevictable: 0,
nr_slab_reclaimable: 8551,
nr_slab_unreclaimable: 8749,
nr_isolated_anon: 0,
nr_isolated_file: 0,
workingset_nodes: 0,
workingset_refault_anon: 0,
workingset_refault_file: 0,
workingset_activate_anon: 0,
workingset_activate_file: 0,
workingset_restore_anon: 0,
workingset_restore_file: 0,
workingset_nodereclaim: 0,
nr_anon_pages: 21233,
nr_mapped: 33359,
nr_file_pages: 0,
nr_dirty: 93023,
nr_writeback: 0,
nr_writeback_temp: 0,
nr_shmem: 0,
nr_shmem_hugepages: 0,
nr_shmem_pmdmapped: 0,
nr_file_hugepages: 0,
nr_file_pmdmapped: 0,
nr_anon_transparent_hugepages: 0,
nr_vmscan_write: 0,
nr_vmscan_immediate_reclaim: 0,
nr_dirtied: 66050,
nr_written: 62014,
nr_throttled_written: 0,
nr_kernel_misc_reclaimable: 0,
nr_foll_pin_acquired: 0,
nr_foll_pin_released: 0,
nr_kernel_stack: 2768,
nr_shadow_call_stack: 712,
nr_page_table_pages: 580,
nr_sec_page_table_pages: 0,
nr_swapcached: 0,
pgpromote_success: 0,
pgpromote_candidate: 0,
nr_dirty_threshold: 0,
nr_dirty_background_threshold: 0,
pgpgin: 569048,
pgpgout: 264157,
pswpin: 0,
pswpout: 0,
pgalloc_dma: 0,
pgalloc_dma32: 0,
pgalloc_normal: 42962188,
pgalloc_movable: 0,
pgalloc_device: 0,
allocstall_dma: 0,
allocstall_dma32: 0,
allocstall_normal: 0,
allocstall_movable: 0,
allocstall_device: 0,
pgskip_dma: 0,
pgskip_dma32: 0,
pgskip_normal: 0,
pgskip_movable: 0,
pgskip_device: 0,
pgfree: 43741863,
pgactivate: 0,
pgdeactivate: 0,
pglazyfree: 0,
pgfault: 55051790,
pgmajfault: 2851,
pglazyfreed: 0,
pgrefill: 0,
pgreuse: 1854584,
pgsteal_kswapd: 0,
pgsteal_direct: 0,
pgsteal_khugepaged: 0,
pgdemote_kswapd: 0,
pgdemote_direct: 0,
pgdemote_khugepaged: 0,
pgscan_kswapd: 0,
pgscan_direct: 0,
pgscan_khugepaged: 0,
pgscan_direct_throttle: 0,
pgscan_anon: 0,
pgscan_file: 0,
pgsteal_anon: 0,
pgsteal_file: 0,
zone_reclaim_failed: 0,
pginodesteal: 0,
slabs_scanned: 0,
kswapd_inodesteal: 0,
kswapd_low_wmark_hit_quickly: 0,
kswapd_high_wmark_hit_quickly: 0,
pageoutrun: 0,
pgrotated: 6,
drop_pagecache: 0,
drop_slab: 0,
oom_kill: 0,
numa_pte_updates: 0,
numa_huge_pte_updates: 0,
numa_hint_faults: 0,
numa_hint_faults_local: 0,
numa_pages_migrated: 0,
pgmigrate_success: 0,
pgmigrate_fail: 0,
thp_migration_success: 0,
thp_migration_fail: 0,
thp_migration_split: 0,
compact_migrate_scanned: 0,
compact_free_scanned: 0,
compact_isolated: 896,
compact_stall: 0,
compact_fail: 0,
compact_success: 0,
compact_daemon_wake: 0,
compact_daemon_migrate_scanned: 0,
compact_daemon_free_scanned: 0,
htlb_buddy_alloc_success: 0,
htlb_buddy_alloc_fail: 0,
cma_alloc_success: 3,
cma_alloc_fail: 0,
unevictable_pgs_culled: 0,
unevictable_pgs_scanned: 0,
unevictable_pgs_rescued: 0,
unevictable_pgs_mlocked: 0,
unevictable_pgs_munlocked: 0,
unevictable_pgs_cleared: 0,
unevictable_pgs_stranded: 0,
thp_fault_alloc: 0,
thp_fault_fallback: 0,
thp_fault_fallback_charge: 0,
thp_collapse_alloc: 0,
thp_collapse_alloc_failed: 0,
thp_file_alloc: 0,
thp_file_fallback: 0,
thp_file_fallback_charge: 0,
thp_file_mapped: 0,
thp_split_page: 0,
thp_split_page_failed: 0,
thp_deferred_split_page: 0,
thp_split_pmd: 0,
thp_scan_exceed_none_pte: 0,
thp_scan_exceed_swap_pte: 0,
thp_scan_exceed_share_pte: 0,
thp_zero_page_alloc: 0,
thp_zero_page_alloc_failed: 0,
thp_swpout: 0,
thp_swpout_fallback: 0,
balloon_inflate: 0,
balloon_deflate: 0,
balloon_migrate: 0,
swap_ra: 0,
swap_ra_hit: 0,
ksm_swpin_copy: 0,
cow_ksm: 0,
zswpin: 0,
zswpout: 0,
nr_unstable: 0,
}
(edited for readability)
If you want to change the path and/or file that is read for ProcVmStat, which is /proc/vmstat
by default, use:
use proc_sys_parser::{vmstat, vmstat::{ProcVmStat, Builder}};
let proc_vmstat = Builder::new().file_name("/myproc/vmstat").read();Structs§
- Builder pattern for
ProcVmStat - Struct for holding
/proc/vmstatstatistics
Functions§
- The main function for building a
ProcVmStatstruct with current data. This uses the Builder pattern, which allows settings such as the filename to specified.