]> arthur.barton.de Git - netdata.git/blob - src/proc_vmstat.c
proc_vmstat.c: update commented list of metrics from /proc/vmstat, NFC
[netdata.git] / src / proc_vmstat.c
1 #include "common.h"
2
3 int do_proc_vmstat(int update_every, usec_t dt) {
4     (void)dt;
5
6     static procfile *ff = NULL;
7     static int do_swapio = -1, do_io = -1, do_pgfaults = -1;
8
9     // static uint32_t hash_allocstall_dma = 0;
10     // static uint32_t hash_allocstall_dma32 = 0;
11     // static uint32_t hash_allocstall_movable = 0;
12     // static uint32_t hash_allocstall_normal = 0;
13     // static uint32_t hash_balloon_deflate = 0;
14     // static uint32_t hash_balloon_inflate = 0;
15     // static uint32_t hash_balloon_migrate = 0;
16     // static uint32_t hash_compact_daemon_wake = 0;
17     // static uint32_t hash_compact_fail = 0;
18     // static uint32_t hash_compact_free_scanned = 0;
19     // static uint32_t hash_compact_isolated = 0;
20     // static uint32_t hash_compact_migrate_scanned = 0;
21     // static uint32_t hash_compact_stall = 0;
22     // static uint32_t hash_compact_success = 0;
23     // static uint32_t hash_drop_pagecache = 0;
24     // static uint32_t hash_drop_slab = 0;
25     // static uint32_t hash_htlb_buddy_alloc_fail = 0;
26     // static uint32_t hash_htlb_buddy_alloc_success = 0;
27     // static uint32_t hash_kswapd_high_wmark_hit_quickly = 0;
28     // static uint32_t hash_kswapd_inodesteal = 0;
29     // static uint32_t hash_kswapd_low_wmark_hit_quickly = 0;
30     // static uint32_t hash_nr_active_anon = 0;
31     // static uint32_t hash_nr_active_file = 0;
32     // static uint32_t hash_nr_anon_pages = 0;
33     // static uint32_t hash_nr_anon_transparent_hugepages = 0;
34     // static uint32_t hash_nr_bounce = 0;
35     // static uint32_t hash_nr_dirtied = 0;
36     // static uint32_t hash_nr_dirty = 0;
37     // static uint32_t hash_nr_dirty_background_threshold = 0;
38     // static uint32_t hash_nr_dirty_threshold = 0;
39     // static uint32_t hash_nr_file_pages = 0;
40     // static uint32_t hash_nr_free_cma = 0;
41     // static uint32_t hash_nr_free_pages = 0;
42     // static uint32_t hash_nr_inactive_anon = 0;
43     // static uint32_t hash_nr_inactive_file = 0;
44     // static uint32_t hash_nr_isolated_anon = 0;
45     // static uint32_t hash_nr_isolated_file = 0;
46     // static uint32_t hash_nr_kernel_stack = 0;
47     // static uint32_t hash_nr_mapped = 0;
48     // static uint32_t hash_nr_mlock = 0;
49     // static uint32_t hash_nr_pages_scanned = 0;
50     // static uint32_t hash_nr_page_table_pages = 0;
51     // static uint32_t hash_nr_shmem = 0;
52     // static uint32_t hash_nr_shmem_hugepages = 0;
53     // static uint32_t hash_nr_shmem_pmdmapped = 0;
54     // static uint32_t hash_nr_slab_reclaimable = 0;
55     // static uint32_t hash_nr_slab_unreclaimable = 0;
56     // static uint32_t hash_nr_unevictable = 0;
57     // static uint32_t hash_nr_unstable = 0;
58     // static uint32_t hash_nr_vmscan_immediate_reclaim = 0;
59     // static uint32_t hash_nr_vmscan_write = 0;
60     // static uint32_t hash_nr_writeback = 0;
61     // static uint32_t hash_nr_writeback_temp = 0;
62     // static uint32_t hash_nr_written = 0;
63     // static uint32_t hash_nr_zone_active_anon = 0;
64     // static uint32_t hash_nr_zone_active_file = 0;
65     // static uint32_t hash_nr_zone_inactive_anon = 0;
66     // static uint32_t hash_nr_zone_inactive_file = 0;
67     // static uint32_t hash_nr_zone_unevictable = 0;
68     // static uint32_t hash_nr_zone_write_pending = 0;
69     // static uint32_t hash_nr_zspages = 0;
70     // static uint32_t hash_numa_foreign = 0;
71     // static uint32_t hash_numa_hint_faults = 0;
72     // static uint32_t hash_numa_hint_faults_local = 0;
73     // static uint32_t hash_numa_hit = 0;
74     // static uint32_t hash_numa_huge_pte_updates = 0;
75     // static uint32_t hash_numa_interleave = 0;
76     // static uint32_t hash_numa_local = 0;
77     // static uint32_t hash_numa_miss = 0;
78     // static uint32_t hash_numa_other = 0;
79     // static uint32_t hash_numa_pages_migrated = 0;
80     // static uint32_t hash_numa_pte_updates = 0;
81     // static uint32_t hash_pageoutrun = 0;
82     // static uint32_t hash_pgactivate = 0;
83     // static uint32_t hash_pgalloc_dma = 0;
84     // static uint32_t hash_pgalloc_dma32 = 0;
85     // static uint32_t hash_pgalloc_movable = 0;
86     // static uint32_t hash_pgalloc_normal = 0;
87     // static uint32_t hash_pgdeactivate = 0;
88     static uint32_t hash_pgfault = 0;
89     // static uint32_t hash_pgfree = 0;
90     // static uint32_t hash_pginodesteal = 0;
91     // static uint32_t hash_pglazyfreed = 0;
92     static uint32_t hash_pgmajfault = 0;
93     // static uint32_t hash_pgmigrate_fail = 0;
94     // static uint32_t hash_pgmigrate_success = 0;
95     static uint32_t hash_pgpgin = 0;
96     static uint32_t hash_pgpgout = 0;
97     // static uint32_t hash_pgrefill = 0;
98     // static uint32_t hash_pgrotated = 0;
99     // static uint32_t hash_pgscan_direct = 0;
100     // static uint32_t hash_pgscan_direct_throttle = 0;
101     // static uint32_t hash_pgscan_kswapd = 0;
102     // static uint32_t hash_pgskip_dma = 0;
103     // static uint32_t hash_pgskip_dma32 = 0;
104     // static uint32_t hash_pgskip_movable = 0;
105     // static uint32_t hash_pgskip_normal = 0;
106     // static uint32_t hash_pgsteal_direct = 0;
107     // static uint32_t hash_pgsteal_kswapd = 0;
108     static uint32_t hash_pswpin = 0;
109     static uint32_t hash_pswpout = 0;
110     // static uint32_t hash_slabs_scanned = 0;
111     // static uint32_t hash_thp_collapse_alloc = 0;
112     // static uint32_t hash_thp_collapse_alloc_failed = 0;
113     // static uint32_t hash_thp_deferred_split_page = 0;
114     // static uint32_t hash_thp_fault_alloc = 0;
115     // static uint32_t hash_thp_fault_fallback = 0;
116     // static uint32_t hash_thp_file_alloc = 0;
117     // static uint32_t hash_thp_file_mapped = 0;
118     // static uint32_t hash_thp_split_page = 0;
119     // static uint32_t hash_thp_split_page_failed = 0;
120     // static uint32_t hash_thp_split_pmd = 0;
121     // static uint32_t hash_thp_zero_page_alloc = 0;
122     // static uint32_t hash_thp_zero_page_alloc_failed = 0;
123     // static uint32_t hash_unevictable_pgs_cleared = 0;
124     // static uint32_t hash_unevictable_pgs_culled = 0;
125     // static uint32_t hash_unevictable_pgs_mlocked = 0;
126     // static uint32_t hash_unevictable_pgs_munlocked = 0;
127     // static uint32_t hash_unevictable_pgs_rescued = 0;
128     // static uint32_t hash_unevictable_pgs_scanned = 0;
129     // static uint32_t hash_unevictable_pgs_stranded = 0;
130     // static uint32_t hash_workingset_activate = 0;
131     // static uint32_t hash_workingset_nodereclaim = 0;
132     // static uint32_t hash_workingset_refault = 0;
133     // static uint32_t hash_zone_reclaim_failed = 0;
134
135     if(unlikely(do_swapio == -1)) {
136         do_swapio = config_get_boolean_ondemand("plugin:proc:/proc/vmstat", "swap i/o", CONFIG_ONDEMAND_ONDEMAND);
137         do_io = config_get_boolean("plugin:proc:/proc/vmstat", "disk i/o", 1);
138         do_pgfaults = config_get_boolean("plugin:proc:/proc/vmstat", "memory page faults", 1);
139
140         // hash_allocstall_dma32 = simple_hash("allocstall_dma32");
141         // hash_allocstall_dma = simple_hash("allocstall_dma");
142         // hash_allocstall_movable = simple_hash("allocstall_movable");
143         // hash_allocstall_normal = simple_hash("allocstall_normal");
144         // hash_balloon_deflate = simple_hash("balloon_deflate");
145         // hash_balloon_inflate = simple_hash("balloon_inflate");
146         // hash_balloon_migrate = simple_hash("balloon_migrate");
147         // hash_compact_daemon_wake = simple_hash("compact_daemon_wake");
148         // hash_compact_fail = simple_hash("compact_fail");
149         // hash_compact_free_scanned = simple_hash("compact_free_scanned");
150         // hash_compact_isolated = simple_hash("compact_isolated");
151         // hash_compact_migrate_scanned = simple_hash("compact_migrate_scanned");
152         // hash_compact_stall = simple_hash("compact_stall");
153         // hash_compact_success = simple_hash("compact_success");
154         // hash_drop_pagecache = simple_hash("drop_pagecache");
155         // hash_drop_slab = simple_hash("drop_slab");
156         // hash_htlb_buddy_alloc_fail = simple_hash("htlb_buddy_alloc_fail");
157         // hash_htlb_buddy_alloc_success = simple_hash("htlb_buddy_alloc_success");
158         // hash_kswapd_high_wmark_hit_quickly = simple_hash("kswapd_high_wmark_hit_quickly");
159         // hash_kswapd_inodesteal = simple_hash("kswapd_inodesteal");
160         // hash_kswapd_low_wmark_hit_quickly = simple_hash("kswapd_low_wmark_hit_quickly");
161         // hash_nr_active_anon = simple_hash("nr_active_anon");
162         // hash_nr_active_file = simple_hash("nr_active_file");
163         // hash_nr_anon_pages = simple_hash("nr_anon_pages");
164         // hash_nr_anon_transparent_hugepages = simple_hash("nr_anon_transparent_hugepages");
165         // hash_nr_bounce = simple_hash("nr_bounce");
166         // hash_nr_dirtied = simple_hash("nr_dirtied");
167         // hash_nr_dirty_background_threshold = simple_hash("nr_dirty_background_threshold");
168         // hash_nr_dirty = simple_hash("nr_dirty");
169         // hash_nr_dirty_threshold = simple_hash("nr_dirty_threshold");
170         // hash_nr_file_pages = simple_hash("nr_file_pages");
171         // hash_nr_free_cma = simple_hash("nr_free_cma");
172         // hash_nr_free_pages = simple_hash("nr_free_pages");
173         // hash_nr_inactive_anon = simple_hash("nr_inactive_anon");
174         // hash_nr_inactive_file = simple_hash("nr_inactive_file");
175         // hash_nr_isolated_anon = simple_hash("nr_isolated_anon");
176         // hash_nr_isolated_file = simple_hash("nr_isolated_file");
177         // hash_nr_kernel_stack = simple_hash("nr_kernel_stack");
178         // hash_nr_mapped = simple_hash("nr_mapped");
179         // hash_nr_mlock = simple_hash("nr_mlock");
180         // hash_nr_pages_scanned = simple_hash("nr_pages_scanned");
181         // hash_nr_page_table_pages = simple_hash("nr_page_table_pages");
182         // hash_nr_shmem_hugepages = simple_hash("nr_shmem_hugepages");
183         // hash_nr_shmem_pmdmapped = simple_hash("nr_shmem_pmdmapped");
184         // hash_nr_shmem = simple_hash("nr_shmem");
185         // hash_nr_slab_reclaimable = simple_hash("nr_slab_reclaimable");
186         // hash_nr_slab_unreclaimable = simple_hash("nr_slab_unreclaimable");
187         // hash_nr_unevictable = simple_hash("nr_unevictable");
188         // hash_nr_unstable = simple_hash("nr_unstable");
189         // hash_nr_vmscan_immediate_reclaim = simple_hash("nr_vmscan_immediate_reclaim");
190         // hash_nr_vmscan_write = simple_hash("nr_vmscan_write");
191         // hash_nr_writeback = simple_hash("nr_writeback");
192         // hash_nr_writeback_temp = simple_hash("nr_writeback_temp");
193         // hash_nr_written = simple_hash("nr_written");
194         // hash_nr_zone_active_anon = simple_hash("nr_zone_active_anon");
195         // hash_nr_zone_active_file = simple_hash("nr_zone_active_file");
196         // hash_nr_zone_inactive_anon = simple_hash("nr_zone_inactive_anon");
197         // hash_nr_zone_inactive_file = simple_hash("nr_zone_inactive_file");
198         // hash_nr_zone_unevictable = simple_hash("nr_zone_unevictable");
199         // hash_nr_zone_write_pending = simple_hash("nr_zone_write_pending");
200         // hash_nr_zspages = simple_hash("nr_zspages");
201         // hash_numa_foreign = simple_hash("numa_foreign");
202         // hash_numa_hint_faults_local = simple_hash("numa_hint_faults_local");
203         // hash_numa_hint_faults = simple_hash("numa_hint_faults");
204         // hash_numa_hit = simple_hash("numa_hit");
205         // hash_numa_huge_pte_updates = simple_hash("numa_huge_pte_updates");
206         // hash_numa_interleave = simple_hash("numa_interleave");
207         // hash_numa_local = simple_hash("numa_local");
208         // hash_numa_miss = simple_hash("numa_miss");
209         // hash_numa_other = simple_hash("numa_other");
210         // hash_numa_pages_migrated = simple_hash("numa_pages_migrated");
211         // hash_numa_pte_updates = simple_hash("numa_pte_updates");
212         // hash_pageoutrun = simple_hash("pageoutrun");
213         // hash_pgactivate = simple_hash("pgactivate");
214         // hash_pgalloc_dma32 = simple_hash("pgalloc_dma32");
215         // hash_pgalloc_dma = simple_hash("pgalloc_dma");
216         // hash_pgalloc_movable = simple_hash("pgalloc_movable");
217         // hash_pgalloc_normal = simple_hash("pgalloc_normal");
218         // hash_pgdeactivate = simple_hash("pgdeactivate");
219         hash_pgfault = simple_hash("pgfault");
220         // hash_pgfree = simple_hash("pgfree");
221         // hash_pginodesteal = simple_hash("pginodesteal");
222         // hash_pglazyfreed = simple_hash("pglazyfreed");
223         hash_pgmajfault = simple_hash("pgmajfault");
224         // hash_pgmigrate_fail = simple_hash("pgmigrate_fail");
225         // hash_pgmigrate_success = simple_hash("pgmigrate_success");
226         hash_pgpgin = simple_hash("pgpgin");
227         hash_pgpgout = simple_hash("pgpgout");
228         // hash_pgrefill = simple_hash("pgrefill");
229         // hash_pgrotated = simple_hash("pgrotated");
230         // hash_pgscan_direct = simple_hash("pgscan_direct");
231         // hash_pgscan_direct_throttle = simple_hash("pgscan_direct_throttle");
232         // hash_pgscan_kswapd = simple_hash("pgscan_kswapd");
233         // hash_pgskip_dma32 = simple_hash("pgskip_dma32");
234         // hash_pgskip_dma = simple_hash("pgskip_dma");
235         // hash_pgskip_movable = simple_hash("pgskip_movable");
236         // hash_pgskip_normal = simple_hash("pgskip_normal");
237         // hash_pgsteal_direct = simple_hash("pgsteal_direct");
238         // hash_pgsteal_kswapd = simple_hash("pgsteal_kswapd");
239         hash_pswpin = simple_hash("pswpin");
240         hash_pswpout = simple_hash("pswpout");
241         // hash_slabs_scanned = simple_hash("slabs_scanned");
242         // hash_thp_collapse_alloc_failed = simple_hash("thp_collapse_alloc_failed");
243         // hash_thp_collapse_alloc = simple_hash("thp_collapse_alloc");
244         // hash_thp_deferred_split_page = simple_hash("thp_deferred_split_page");
245         // hash_thp_fault_alloc = simple_hash("thp_fault_alloc");
246         // hash_thp_fault_fallback = simple_hash("thp_fault_fallback");
247         // hash_thp_file_alloc = simple_hash("thp_file_alloc");
248         // hash_thp_file_mapped = simple_hash("thp_file_mapped");
249         // hash_thp_split_page_failed = simple_hash("thp_split_page_failed");
250         // hash_thp_split_page = simple_hash("thp_split_page");
251         // hash_thp_split_pmd = simple_hash("thp_split_pmd");
252         // hash_thp_zero_page_alloc_failed = simple_hash("thp_zero_page_alloc_failed");
253         // hash_thp_zero_page_alloc = simple_hash("thp_zero_page_alloc");
254         // hash_unevictable_pgs_cleared = simple_hash("unevictable_pgs_cleared");
255         // hash_unevictable_pgs_culled = simple_hash("unevictable_pgs_culled");
256         // hash_unevictable_pgs_mlocked = simple_hash("unevictable_pgs_mlocked");
257         // hash_unevictable_pgs_munlocked = simple_hash("unevictable_pgs_munlocked");
258         // hash_unevictable_pgs_rescued = simple_hash("unevictable_pgs_rescued");
259         // hash_unevictable_pgs_scanned = simple_hash("unevictable_pgs_scanned");
260         // hash_unevictable_pgs_stranded = simple_hash("unevictable_pgs_stranded");
261         // hash_workingset_activate = simple_hash("workingset_activate");
262         // hash_workingset_nodereclaim = simple_hash("workingset_nodereclaim");
263         // hash_workingset_refault = simple_hash("workingset_refault");
264         // hash_zone_reclaim_failed = simple_hash("zone_reclaim_failed");
265     }
266
267     if(unlikely(!ff)) {
268         char filename[FILENAME_MAX + 1];
269         snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/vmstat");
270         ff = procfile_open(config_get("plugin:proc:/proc/vmstat", "filename to monitor", filename), " \t:", PROCFILE_FLAG_DEFAULT);
271         if(unlikely(!ff)) return 1;
272     }
273
274     ff = procfile_readall(ff);
275     if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time
276
277     uint32_t lines = procfile_lines(ff), l;
278
279     // unsigned long long allocstall_dma = 0ULL;
280     // unsigned long long allocstall_dma32 = 0ULL;
281     // unsigned long long allocstall_movable = 0ULL;
282     // unsigned long long allocstall_normal = 0ULL;
283     // unsigned long long balloon_deflate = 0ULL;
284     // unsigned long long balloon_inflate = 0ULL;
285     // unsigned long long balloon_migrate = 0ULL;
286     // unsigned long long compact_daemon_wake = 0ULL;
287     // unsigned long long compact_fail = 0ULL;
288     // unsigned long long compact_free_scanned = 0ULL;
289     // unsigned long long compact_isolated = 0ULL;
290     // unsigned long long compact_migrate_scanned = 0ULL;
291     // unsigned long long compact_stall = 0ULL;
292     // unsigned long long compact_success = 0ULL;
293     // unsigned long long drop_pagecache = 0ULL;
294     // unsigned long long drop_slab = 0ULL;
295     // unsigned long long htlb_buddy_alloc_fail = 0ULL;
296     // unsigned long long htlb_buddy_alloc_success = 0ULL;
297     // unsigned long long kswapd_high_wmark_hit_quickly = 0ULL;
298     // unsigned long long kswapd_inodesteal = 0ULL;
299     // unsigned long long kswapd_low_wmark_hit_quickly = 0ULL;
300     // unsigned long long nr_active_anon = 0ULL;
301     // unsigned long long nr_active_file = 0ULL;
302     // unsigned long long nr_anon_pages = 0ULL;
303     // unsigned long long nr_anon_transparent_hugepages = 0ULL;
304     // unsigned long long nr_bounce = 0ULL;
305     // unsigned long long nr_dirtied = 0ULL;
306     // unsigned long long nr_dirty = 0ULL;
307     // unsigned long long nr_dirty_background_threshold = 0ULL;
308     // unsigned long long nr_dirty_threshold = 0ULL;
309     // unsigned long long nr_file_pages = 0ULL;
310     // unsigned long long nr_free_cma = 0ULL;
311     // unsigned long long nr_free_pages = 0ULL;
312     // unsigned long long nr_inactive_anon = 0ULL;
313     // unsigned long long nr_inactive_file = 0ULL;
314     // unsigned long long nr_isolated_anon = 0ULL;
315     // unsigned long long nr_isolated_file = 0ULL;
316     // unsigned long long nr_kernel_stack = 0ULL;
317     // unsigned long long nr_mapped = 0ULL;
318     // unsigned long long nr_mlock = 0ULL;
319     // unsigned long long nr_pages_scanned = 0ULL;
320     // unsigned long long nr_page_table_pages = 0ULL;
321     // unsigned long long nr_shmem = 0ULL;
322     // unsigned long long nr_shmem_hugepages = 0ULL;
323     // unsigned long long nr_shmem_pmdmapped = 0ULL;
324     // unsigned long long nr_slab_reclaimable = 0ULL;
325     // unsigned long long nr_slab_unreclaimable = 0ULL;
326     // unsigned long long nr_unevictable = 0ULL;
327     // unsigned long long nr_unstable = 0ULL;
328     // unsigned long long nr_vmscan_immediate_reclaim = 0ULL;
329     // unsigned long long nr_vmscan_write = 0ULL;
330     // unsigned long long nr_writeback = 0ULL;
331     // unsigned long long nr_writeback_temp = 0ULL;
332     // unsigned long long nr_written = 0ULL;
333     // unsigned long long nr_zone_active_anon = 0ULL;
334     // unsigned long long nr_zone_active_file = 0ULL;
335     // unsigned long long nr_zone_inactive_anon = 0ULL;
336     // unsigned long long nr_zone_inactive_file = 0ULL;
337     // unsigned long long nr_zone_unevictable = 0ULL;
338     // unsigned long long nr_zone_write_pending = 0ULL;
339     // unsigned long long nr_zspages = 0ULL;
340     // unsigned long long numa_foreign = 0ULL;
341     // unsigned long long numa_hint_faults = 0ULL;
342     // unsigned long long numa_hint_faults_local = 0ULL;
343     // unsigned long long numa_hit = 0ULL;
344     // unsigned long long numa_huge_pte_updates = 0ULL;
345     // unsigned long long numa_interleave = 0ULL;
346     // unsigned long long numa_local = 0ULL;
347     // unsigned long long numa_miss = 0ULL;
348     // unsigned long long numa_other = 0ULL;
349     // unsigned long long numa_pages_migrated = 0ULL;
350     // unsigned long long numa_pte_updates = 0ULL;
351     // unsigned long long pageoutrun = 0ULL;
352     // unsigned long long pgactivate = 0ULL;
353     // unsigned long long pgalloc_dma = 0ULL;
354     // unsigned long long pgalloc_dma32 = 0ULL;
355     // unsigned long long pgalloc_movable = 0ULL;
356     // unsigned long long pgalloc_normal = 0ULL;
357     // unsigned long long pgdeactivate = 0ULL;
358     unsigned long long pgfault = 0ULL;
359     // unsigned long long pgfree = 0ULL;
360     // unsigned long long pginodesteal = 0ULL;
361     // unsigned long long pglazyfreed = 0ULL;
362     unsigned long long pgmajfault = 0ULL;
363     // unsigned long long pgmigrate_fail = 0ULL;
364     // unsigned long long pgmigrate_success = 0ULL;
365     unsigned long long pgpgin = 0ULL;
366     unsigned long long pgpgout = 0ULL;
367     // unsigned long long pgrefill = 0ULL;
368     // unsigned long long pgrotated = 0ULL;
369     // unsigned long long pgscan_direct = 0ULL;
370     // unsigned long long pgscan_direct_throttle = 0ULL;
371     // unsigned long long pgscan_kswapd = 0ULL;
372     // unsigned long long pgskip_dma = 0ULL;
373     // unsigned long long pgskip_dma32 = 0ULL;
374     // unsigned long long pgskip_movable = 0ULL;
375     // unsigned long long pgskip_normal = 0ULL;
376     // unsigned long long pgsteal_direct = 0ULL;
377     // unsigned long long pgsteal_kswapd = 0ULL;
378     unsigned long long pswpin = 0ULL;
379     unsigned long long pswpout = 0ULL;
380     // unsigned long long slabs_scanned = 0ULL;
381     // unsigned long long thp_collapse_alloc = 0ULL;
382     // unsigned long long thp_collapse_alloc_failed = 0ULL;
383     // unsigned long long thp_deferred_split_page = 0ULL;
384     // unsigned long long thp_fault_alloc = 0ULL;
385     // unsigned long long thp_fault_fallback = 0ULL;
386     // unsigned long long thp_file_alloc = 0ULL;
387     // unsigned long long thp_file_mapped = 0ULL;
388     // unsigned long long thp_split_page = 0ULL;
389     // unsigned long long thp_split_page_failed = 0ULL;
390     // unsigned long long thp_split_pmd = 0ULL;
391     // unsigned long long thp_zero_page_alloc = 0ULL;
392     // unsigned long long thp_zero_page_alloc_failed = 0ULL;
393     // unsigned long long unevictable_pgs_cleared = 0ULL;
394     // unsigned long long unevictable_pgs_culled = 0ULL;
395     // unsigned long long unevictable_pgs_mlocked = 0ULL;
396     // unsigned long long unevictable_pgs_munlocked = 0ULL;
397     // unsigned long long unevictable_pgs_rescued = 0ULL;
398     // unsigned long long unevictable_pgs_scanned = 0ULL;
399     // unsigned long long unevictable_pgs_stranded = 0ULL;
400     // unsigned long long workingset_activate = 0ULL;
401     // unsigned long long workingset_nodereclaim = 0ULL;
402     // unsigned long long workingset_refault = 0ULL;
403     // unsigned long long zone_reclaim_failed = 0ULL;
404
405     for(l = 0; l < lines ;l++) {
406         uint32_t words = procfile_linewords(ff, l);
407         if(unlikely(words < 2)) {
408             if(unlikely(words)) error("Cannot read /proc/vmstat line %u. Expected 2 params, read %u.", l, words);
409             continue;
410         }
411
412         char *name = procfile_lineword(ff, l, 0);
413         char * value = procfile_lineword(ff, l, 1);
414         if(unlikely(!name || !*name || !value || !*value)) continue;
415
416         uint32_t hash = simple_hash(name);
417
418         if(unlikely(0)) ;
419         // else if(unlikely(hash == hash_allocstall_dma32 && strcmp(name, "allocstall_dma32") == 0)) allocstall_dma32 = strtoull(value, NULL, 10);
420         // else if(unlikely(hash == hash_allocstall_dma && strcmp(name, "allocstall_dma") == 0)) allocstall_dma = strtoull(value, NULL, 10);
421         // else if(unlikely(hash == hash_allocstall_movable && strcmp(name, "allocstall_movable") == 0)) allocstall_movable = strtoull(value, NULL, 10);
422         // else if(unlikely(hash == hash_allocstall_normal && strcmp(name, "allocstall_normal") == 0)) allocstall_normal = strtoull(value, NULL, 10);
423         // else if(unlikely(hash == hash_balloon_deflate && strcmp(name, "balloon_deflate") == 0)) balloon_deflate = strtoull(value, NULL, 10);
424         // else if(unlikely(hash == hash_balloon_inflate && strcmp(name, "balloon_inflate") == 0)) balloon_inflate = strtoull(value, NULL, 10);
425         // else if(unlikely(hash == hash_balloon_migrate && strcmp(name, "balloon_migrate") == 0)) balloon_migrate = strtoull(value, NULL, 10);
426         // else if(unlikely(hash == hash_compact_daemon_wake && strcmp(name, "compact_daemon_wake") == 0)) compact_daemon_wake = strtoull(value, NULL, 10);
427         // else if(unlikely(hash == hash_compact_fail && strcmp(name, "compact_fail") == 0)) compact_fail = strtoull(value, NULL, 10);
428         // else if(unlikely(hash == hash_compact_free_scanned && strcmp(name, "compact_free_scanned") == 0)) compact_free_scanned = strtoull(value, NULL, 10);
429         // else if(unlikely(hash == hash_compact_isolated && strcmp(name, "compact_isolated") == 0)) compact_isolated = strtoull(value, NULL, 10);
430         // else if(unlikely(hash == hash_compact_migrate_scanned && strcmp(name, "compact_migrate_scanned") == 0)) compact_migrate_scanned = strtoull(value, NULL, 10);
431         // else if(unlikely(hash == hash_compact_stall && strcmp(name, "compact_stall") == 0)) compact_stall = strtoull(value, NULL, 10);
432         // else if(unlikely(hash == hash_compact_success && strcmp(name, "compact_success") == 0)) compact_success = strtoull(value, NULL, 10);
433         // else if(unlikely(hash == hash_drop_pagecache && strcmp(name, "drop_pagecache") == 0)) drop_pagecache = strtoull(value, NULL, 10);
434         // else if(unlikely(hash == hash_drop_slab && strcmp(name, "drop_slab") == 0)) drop_slab = strtoull(value, NULL, 10);
435         // else if(unlikely(hash == hash_htlb_buddy_alloc_fail && strcmp(name, "htlb_buddy_alloc_fail") == 0)) htlb_buddy_alloc_fail = strtoull(value, NULL, 10);
436         // else if(unlikely(hash == hash_htlb_buddy_alloc_success && strcmp(name, "htlb_buddy_alloc_success") == 0)) htlb_buddy_alloc_success = strtoull(value, NULL, 10);
437         // else if(unlikely(hash == hash_kswapd_high_wmark_hit_quickly && strcmp(name, "kswapd_high_wmark_hit_quickly") == 0)) kswapd_high_wmark_hit_quickly = strtoull(value, NULL, 10);
438         // else if(unlikely(hash == hash_kswapd_inodesteal && strcmp(name, "kswapd_inodesteal") == 0)) kswapd_inodesteal = strtoull(value, NULL, 10);
439         // else if(unlikely(hash == hash_kswapd_low_wmark_hit_quickly && strcmp(name, "kswapd_low_wmark_hit_quickly") == 0)) kswapd_low_wmark_hit_quickly = strtoull(value, NULL, 10);
440         // else if(unlikely(hash == hash_nr_active_anon && strcmp(name, "nr_active_anon") == 0)) nr_active_anon = strtoull(value, NULL, 10);
441         // else if(unlikely(hash == hash_nr_active_file && strcmp(name, "nr_active_file") == 0)) nr_active_file = strtoull(value, NULL, 10);
442         // else if(unlikely(hash == hash_nr_anon_pages && strcmp(name, "nr_anon_pages") == 0)) nr_anon_pages = strtoull(value, NULL, 10);
443         // else if(unlikely(hash == hash_nr_anon_transparent_hugepages && strcmp(name, "nr_anon_transparent_hugepages") == 0)) nr_anon_transparent_hugepages = strtoull(value, NULL, 10);
444         // else if(unlikely(hash == hash_nr_bounce && strcmp(name, "nr_bounce") == 0)) nr_bounce = strtoull(value, NULL, 10);
445         // else if(unlikely(hash == hash_nr_dirtied && strcmp(name, "nr_dirtied") == 0)) nr_dirtied = strtoull(value, NULL, 10);
446         // else if(unlikely(hash == hash_nr_dirty_background_threshold && strcmp(name, "nr_dirty_background_threshold") == 0)) nr_dirty_background_threshold = strtoull(value, NULL, 10);
447         // else if(unlikely(hash == hash_nr_dirty && strcmp(name, "nr_dirty") == 0)) nr_dirty = strtoull(value, NULL, 10);
448         // else if(unlikely(hash == hash_nr_dirty_threshold && strcmp(name, "nr_dirty_threshold") == 0)) nr_dirty_threshold = strtoull(value, NULL, 10);
449         // else if(unlikely(hash == hash_nr_file_pages && strcmp(name, "nr_file_pages") == 0)) nr_file_pages = strtoull(value, NULL, 10);
450         // else if(unlikely(hash == hash_nr_free_cma && strcmp(name, "nr_free_cma") == 0)) nr_free_cma = strtoull(value, NULL, 10);
451         // else if(unlikely(hash == hash_nr_free_pages && strcmp(name, "nr_free_pages") == 0)) nr_free_pages = strtoull(value, NULL, 10);
452         // else if(unlikely(hash == hash_nr_inactive_anon && strcmp(name, "nr_inactive_anon") == 0)) nr_inactive_anon = strtoull(value, NULL, 10);
453         // else if(unlikely(hash == hash_nr_inactive_file && strcmp(name, "nr_inactive_file") == 0)) nr_inactive_file = strtoull(value, NULL, 10);
454         // else if(unlikely(hash == hash_nr_isolated_anon && strcmp(name, "nr_isolated_anon") == 0)) nr_isolated_anon = strtoull(value, NULL, 10);
455         // else if(unlikely(hash == hash_nr_isolated_file && strcmp(name, "nr_isolated_file") == 0)) nr_isolated_file = strtoull(value, NULL, 10);
456         // else if(unlikely(hash == hash_nr_kernel_stack && strcmp(name, "nr_kernel_stack") == 0)) nr_kernel_stack = strtoull(value, NULL, 10);
457         // else if(unlikely(hash == hash_nr_mapped && strcmp(name, "nr_mapped") == 0)) nr_mapped = strtoull(value, NULL, 10);
458         // else if(unlikely(hash == hash_nr_mlock && strcmp(name, "nr_mlock") == 0)) nr_mlock = strtoull(value, NULL, 10);
459         // else if(unlikely(hash == hash_nr_pages_scanned && strcmp(name, "nr_pages_scanned") == 0)) nr_pages_scanned = strtoull(value, NULL, 10);
460         // else if(unlikely(hash == hash_nr_page_table_pages && strcmp(name, "nr_page_table_pages") == 0)) nr_page_table_pages = strtoull(value, NULL, 10);
461         // else if(unlikely(hash == hash_nr_shmem_hugepages && strcmp(name, "nr_shmem_hugepages") == 0)) nr_shmem_hugepages = strtoull(value, NULL, 10);
462         // else if(unlikely(hash == hash_nr_shmem_pmdmapped && strcmp(name, "nr_shmem_pmdmapped") == 0)) nr_shmem_pmdmapped = strtoull(value, NULL, 10);
463         // else if(unlikely(hash == hash_nr_shmem && strcmp(name, "nr_shmem") == 0)) nr_shmem = strtoull(value, NULL, 10);
464         // else if(unlikely(hash == hash_nr_slab_reclaimable && strcmp(name, "nr_slab_reclaimable") == 0)) nr_slab_reclaimable = strtoull(value, NULL, 10);
465         // else if(unlikely(hash == hash_nr_slab_unreclaimable && strcmp(name, "nr_slab_unreclaimable") == 0)) nr_slab_unreclaimable = strtoull(value, NULL, 10);
466         // else if(unlikely(hash == hash_nr_unevictable && strcmp(name, "nr_unevictable") == 0)) nr_unevictable = strtoull(value, NULL, 10);
467         // else if(unlikely(hash == hash_nr_unstable && strcmp(name, "nr_unstable") == 0)) nr_unstable = strtoull(value, NULL, 10);
468         // else if(unlikely(hash == hash_nr_vmscan_immediate_reclaim && strcmp(name, "nr_vmscan_immediate_reclaim") == 0)) nr_vmscan_immediate_reclaim = strtoull(value, NULL, 10);
469         // else if(unlikely(hash == hash_nr_vmscan_write && strcmp(name, "nr_vmscan_write") == 0)) nr_vmscan_write = strtoull(value, NULL, 10);
470         // else if(unlikely(hash == hash_nr_writeback && strcmp(name, "nr_writeback") == 0)) nr_writeback = strtoull(value, NULL, 10);
471         // else if(unlikely(hash == hash_nr_writeback_temp && strcmp(name, "nr_writeback_temp") == 0)) nr_writeback_temp = strtoull(value, NULL, 10);
472         // else if(unlikely(hash == hash_nr_written && strcmp(name, "nr_written") == 0)) nr_written = strtoull(value, NULL, 10);
473         // else if(unlikely(hash == hash_nr_zone_active_anon && strcmp(name, "nr_zone_active_anon") == 0)) nr_zone_active_anon = strtoull(value, NULL, 10);
474         // else if(unlikely(hash == hash_nr_zone_active_file && strcmp(name, "nr_zone_active_file") == 0)) nr_zone_active_file = strtoull(value, NULL, 10);
475         // else if(unlikely(hash == hash_nr_zone_inactive_anon && strcmp(name, "nr_zone_inactive_anon") == 0)) nr_zone_inactive_anon = strtoull(value, NULL, 10);
476         // else if(unlikely(hash == hash_nr_zone_inactive_file && strcmp(name, "nr_zone_inactive_file") == 0)) nr_zone_inactive_file = strtoull(value, NULL, 10);
477         // else if(unlikely(hash == hash_nr_zone_unevictable && strcmp(name, "nr_zone_unevictable") == 0)) nr_zone_unevictable = strtoull(value, NULL, 10);
478         // else if(unlikely(hash == hash_nr_zone_write_pending && strcmp(name, "nr_zone_write_pending") == 0)) nr_zone_write_pending = strtoull(value, NULL, 10);
479         // else if(unlikely(hash == hash_nr_zspages && strcmp(name, "nr_zspages") == 0)) nr_zspages = strtoull(value, NULL, 10);
480         // else if(unlikely(hash == hash_numa_foreign && strcmp(name, "numa_foreign") == 0)) numa_foreign = strtoull(value, NULL, 10);
481         // else if(unlikely(hash == hash_numa_hint_faults_local && strcmp(name, "numa_hint_faults_local") == 0)) numa_hint_faults_local = strtoull(value, NULL, 10);
482         // else if(unlikely(hash == hash_numa_hint_faults && strcmp(name, "numa_hint_faults") == 0)) numa_hint_faults = strtoull(value, NULL, 10);
483         // else if(unlikely(hash == hash_numa_hit && strcmp(name, "numa_hit") == 0)) numa_hit = strtoull(value, NULL, 10);
484         // else if(unlikely(hash == hash_numa_huge_pte_updates && strcmp(name, "numa_huge_pte_updates") == 0)) numa_huge_pte_updates = strtoull(value, NULL, 10);
485         // else if(unlikely(hash == hash_numa_interleave && strcmp(name, "numa_interleave") == 0)) numa_interleave = strtoull(value, NULL, 10);
486         // else if(unlikely(hash == hash_numa_local && strcmp(name, "numa_local") == 0)) numa_local = strtoull(value, NULL, 10);
487         // else if(unlikely(hash == hash_numa_miss && strcmp(name, "numa_miss") == 0)) numa_miss = strtoull(value, NULL, 10);
488         // else if(unlikely(hash == hash_numa_other && strcmp(name, "numa_other") == 0)) numa_other = strtoull(value, NULL, 10);
489         // else if(unlikely(hash == hash_numa_pages_migrated && strcmp(name, "numa_pages_migrated") == 0)) numa_pages_migrated = strtoull(value, NULL, 10);
490         // else if(unlikely(hash == hash_numa_pte_updates && strcmp(name, "numa_pte_updates") == 0)) numa_pte_updates = strtoull(value, NULL, 10);
491         // else if(unlikely(hash == hash_pageoutrun && strcmp(name, "pageoutrun") == 0)) pageoutrun = strtoull(value, NULL, 10);
492         // else if(unlikely(hash == hash_pgactivate && strcmp(name, "pgactivate") == 0)) pgactivate = strtoull(value, NULL, 10);
493         // else if(unlikely(hash == hash_pgalloc_dma32 && strcmp(name, "pgalloc_dma32") == 0)) pgalloc_dma32 = strtoull(value, NULL, 10);
494         // else if(unlikely(hash == hash_pgalloc_dma && strcmp(name, "pgalloc_dma") == 0)) pgalloc_dma = strtoull(value, NULL, 10);
495         // else if(unlikely(hash == hash_pgalloc_movable && strcmp(name, "pgalloc_movable") == 0)) pgalloc_movable = strtoull(value, NULL, 10);
496         // else if(unlikely(hash == hash_pgalloc_normal && strcmp(name, "pgalloc_normal") == 0)) pgalloc_normal = strtoull(value, NULL, 10);
497         // else if(unlikely(hash == hash_pgdeactivate && strcmp(name, "pgdeactivate") == 0)) pgdeactivate = strtoull(value, NULL, 10);
498         else if(unlikely(hash == hash_pgfault && strcmp(name, "pgfault") == 0)) pgfault = strtoull(value, NULL, 10);
499         // else if(unlikely(hash == hash_pgfree && strcmp(name, "pgfree") == 0)) pgfree = strtoull(value, NULL, 10);
500         // else if(unlikely(hash == hash_pginodesteal && strcmp(name, "pginodesteal") == 0)) pginodesteal = strtoull(value, NULL, 10);
501         // else if(unlikely(hash == hash_pglazyfreed && strcmp(name, "pglazyfreed") == 0)) pglazyfreed = strtoull(value, NULL, 10);
502         else if(unlikely(hash == hash_pgmajfault && strcmp(name, "pgmajfault") == 0)) pgmajfault = strtoull(value, NULL, 10);
503         // else if(unlikely(hash == hash_pgmigrate_fail && strcmp(name, "pgmigrate_fail") == 0)) pgmigrate_fail = strtoull(value, NULL, 10);
504         // else if(unlikely(hash == hash_pgmigrate_success && strcmp(name, "pgmigrate_success") == 0)) pgmigrate_success = strtoull(value, NULL, 10);
505         else if(unlikely(hash == hash_pgpgin && strcmp(name, "pgpgin") == 0)) pgpgin = strtoull(value, NULL, 10);
506         else if(unlikely(hash == hash_pgpgout && strcmp(name, "pgpgout") == 0)) pgpgout = strtoull(value, NULL, 10);
507         // else if(unlikely(hash == hash_pgrefill && strcmp(name, "pgrefill") == 0)) pgrefill = strtoull(value, NULL, 10);
508         // else if(unlikely(hash == hash_pgrotated && strcmp(name, "pgrotated") == 0)) pgrotated = strtoull(value, NULL, 10);
509         // else if(unlikely(hash == hash_pgscan_direct && strcmp(name, "pgscan_direct") == 0)) pgscan_direct = strtoull(value, NULL, 10);
510         // else if(unlikely(hash == hash_pgscan_direct_throttle && strcmp(name, "pgscan_direct_throttle") == 0)) pgscan_direct_throttle = strtoull(value, NULL, 10);
511         // else if(unlikely(hash == hash_pgscan_kswapd && strcmp(name, "pgscan_kswapd") == 0)) pgscan_kswapd = strtoull(value, NULL, 10);
512         // else if(unlikely(hash == hash_pgskip_dma32 && strcmp(name, "pgskip_dma32") == 0)) pgskip_dma32 = strtoull(value, NULL, 10);
513         // else if(unlikely(hash == hash_pgskip_dma && strcmp(name, "pgskip_dma") == 0)) pgskip_dma = strtoull(value, NULL, 10);
514         // else if(unlikely(hash == hash_pgskip_movable && strcmp(name, "pgskip_movable") == 0)) pgskip_movable = strtoull(value, NULL, 10);
515         // else if(unlikely(hash == hash_pgskip_normal && strcmp(name, "pgskip_normal") == 0)) pgskip_normal = strtoull(value, NULL, 10);
516         // else if(unlikely(hash == hash_pgsteal_direct && strcmp(name, "pgsteal_direct") == 0)) pgsteal_direct = strtoull(value, NULL, 10);
517         // else if(unlikely(hash == hash_pgsteal_kswapd && strcmp(name, "pgsteal_kswapd") == 0)) pgsteal_kswapd = strtoull(value, NULL, 10);
518         else if(unlikely(hash == hash_pswpin && strcmp(name, "pswpin") == 0)) pswpin = strtoull(value, NULL, 10);
519         else if(unlikely(hash == hash_pswpout && strcmp(name, "pswpout") == 0)) pswpout = strtoull(value, NULL, 10);
520         // else if(unlikely(hash == hash_slabs_scanned && strcmp(name, "slabs_scanned") == 0)) slabs_scanned = strtoull(value, NULL, 10);
521         // else if(unlikely(hash == hash_thp_collapse_alloc_failed && strcmp(name, "thp_collapse_alloc_failed") == 0)) thp_collapse_alloc_failed = strtoull(value, NULL, 10);
522         // else if(unlikely(hash == hash_thp_collapse_alloc && strcmp(name, "thp_collapse_alloc") == 0)) thp_collapse_alloc = strtoull(value, NULL, 10);
523         // else if(unlikely(hash == hash_thp_deferred_split_page && strcmp(name, "thp_deferred_split_page") == 0)) thp_deferred_split_page = strtoull(value, NULL, 10);
524         // else if(unlikely(hash == hash_thp_fault_alloc && strcmp(name, "thp_fault_alloc") == 0)) thp_fault_alloc = strtoull(value, NULL, 10);
525         // else if(unlikely(hash == hash_thp_fault_fallback && strcmp(name, "thp_fault_fallback") == 0)) thp_fault_fallback = strtoull(value, NULL, 10);
526         // else if(unlikely(hash == hash_thp_file_alloc && strcmp(name, "thp_file_alloc") == 0)) thp_file_alloc = strtoull(value, NULL, 10);
527         // else if(unlikely(hash == hash_thp_file_mapped && strcmp(name, "thp_file_mapped") == 0)) thp_file_mapped = strtoull(value, NULL, 10);
528         // else if(unlikely(hash == hash_thp_split_page_failed && strcmp(name, "thp_split_page_failed") == 0)) thp_split_page_failed = strtoull(value, NULL, 10);
529         // else if(unlikely(hash == hash_thp_split_page && strcmp(name, "thp_split_page") == 0)) thp_split_page = strtoull(value, NULL, 10);
530         // else if(unlikely(hash == hash_thp_split_pmd && strcmp(name, "thp_split_pmd") == 0)) thp_split_pmd = strtoull(value, NULL, 10);
531         // else if(unlikely(hash == hash_thp_zero_page_alloc_failed && strcmp(name, "thp_zero_page_alloc_failed") == 0)) thp_zero_page_alloc_failed = strtoull(value, NULL, 10);
532         // else if(unlikely(hash == hash_thp_zero_page_alloc && strcmp(name, "thp_zero_page_alloc") == 0)) thp_zero_page_alloc = strtoull(value, NULL, 10);
533         // else if(unlikely(hash == hash_unevictable_pgs_cleared && strcmp(name, "unevictable_pgs_cleared") == 0)) unevictable_pgs_cleared = strtoull(value, NULL, 10);
534         // else if(unlikely(hash == hash_unevictable_pgs_culled && strcmp(name, "unevictable_pgs_culled") == 0)) unevictable_pgs_culled = strtoull(value, NULL, 10);
535         // else if(unlikely(hash == hash_unevictable_pgs_mlocked && strcmp(name, "unevictable_pgs_mlocked") == 0)) unevictable_pgs_mlocked = strtoull(value, NULL, 10);
536         // else if(unlikely(hash == hash_unevictable_pgs_munlocked && strcmp(name, "unevictable_pgs_munlocked") == 0)) unevictable_pgs_munlocked = strtoull(value, NULL, 10);
537         // else if(unlikely(hash == hash_unevictable_pgs_rescued && strcmp(name, "unevictable_pgs_rescued") == 0)) unevictable_pgs_rescued = strtoull(value, NULL, 10);
538         // else if(unlikely(hash == hash_unevictable_pgs_scanned && strcmp(name, "unevictable_pgs_scanned") == 0)) unevictable_pgs_scanned = strtoull(value, NULL, 10);
539         // else if(unlikely(hash == hash_unevictable_pgs_stranded && strcmp(name, "unevictable_pgs_stranded") == 0)) unevictable_pgs_stranded = strtoull(value, NULL, 10);
540         // else if(unlikely(hash == hash_workingset_activate && strcmp(name, "workingset_activate") == 0)) workingset_activate = strtoull(value, NULL, 10);
541         // else if(unlikely(hash == hash_workingset_nodereclaim && strcmp(name, "workingset_nodereclaim") == 0)) workingset_nodereclaim = strtoull(value, NULL, 10);
542         // else if(unlikely(hash == hash_workingset_refault && strcmp(name, "workingset_refault") == 0)) workingset_refault = strtoull(value, NULL, 10);
543         // else if(unlikely(hash == hash_zone_reclaim_failed && strcmp(name, "zone_reclaim_failed") == 0)) zone_reclaim_failed = strtoull(value, NULL, 10);
544     }
545
546     // --------------------------------------------------------------------
547
548     if(pswpin || pswpout || do_swapio == CONFIG_ONDEMAND_YES) {
549         do_swapio = CONFIG_ONDEMAND_YES;
550
551         static RRDSET *st_swapio = NULL;
552         if(unlikely(!st_swapio)) {
553             st_swapio = rrdset_create("system", "swapio", NULL, "swap", NULL, "Swap I/O", "kilobytes/s", 250, update_every, RRDSET_TYPE_AREA);
554
555             rrddim_add(st_swapio, "in",  NULL, sysconf(_SC_PAGESIZE), 1024, RRDDIM_INCREMENTAL);
556             rrddim_add(st_swapio, "out", NULL, -sysconf(_SC_PAGESIZE), 1024, RRDDIM_INCREMENTAL);
557         }
558         else rrdset_next(st_swapio);
559
560         rrddim_set(st_swapio, "in", pswpin);
561         rrddim_set(st_swapio, "out", pswpout);
562         rrdset_done(st_swapio);
563     }
564
565     // --------------------------------------------------------------------
566
567     if(do_io) {
568         static RRDSET *st_io = NULL;
569         if(unlikely(!st_io)) {
570             st_io = rrdset_create("system", "io", NULL, "disk", NULL, "Disk I/O", "kilobytes/s", 150, update_every, RRDSET_TYPE_AREA);
571
572             rrddim_add(st_io, "in",  NULL,  1, 1, RRDDIM_INCREMENTAL);
573             rrddim_add(st_io, "out", NULL, -1, 1, RRDDIM_INCREMENTAL);
574         }
575         else rrdset_next(st_io);
576
577         rrddim_set(st_io, "in", pgpgin);
578         rrddim_set(st_io, "out", pgpgout);
579         rrdset_done(st_io);
580     }
581
582     // --------------------------------------------------------------------
583
584     if(do_pgfaults) {
585         static RRDSET *st_pgfaults = NULL;
586         if(unlikely(!st_pgfaults)) {
587             st_pgfaults = rrdset_create("mem", "pgfaults", NULL, "system", NULL, "Memory Page Faults", "page faults/s", 500, update_every, RRDSET_TYPE_LINE);
588             st_pgfaults->isdetail = 1;
589
590             rrddim_add(st_pgfaults, "minor",  NULL,  1, 1, RRDDIM_INCREMENTAL);
591             rrddim_add(st_pgfaults, "major", NULL, -1, 1, RRDDIM_INCREMENTAL);
592         }
593         else rrdset_next(st_pgfaults);
594
595         rrddim_set(st_pgfaults, "minor", pgfault);
596         rrddim_set(st_pgfaults, "major", pgmajfault);
597         rrdset_done(st_pgfaults);
598     }
599
600     return 0;
601 }
602