Paging data is found by reading the file “/proc/stat” on older Linux Kernels, and “/proc/vmstat” on newer systems.
Since the data is cumulative the difference since the last data gathering is used as the basis for calculating paging in KB/s .
Typical equation that we use in cdm probe for calculating paging activity is
paging_kbps = paging_delta * pagesize / interval
paging delta = paging at time 1 – paging at time 2
pagesize* = the number of kilo bytes in a memory page
interval = (time1 - time2)
*pagesize is calculated using system call getpagesize(). This call gives the number of bytes in a memory page.
For reference http://man7.org/linux/man-pages/man2/getpagesize.2.html
In CDM probe we use “/proc/vmstat” file , for getting paging .
This file contains pswpin and pswpout parameters among other paramters . paging is sum of values of pswapin and pswapout.
So we calculate paging (pswapin+pswapout) at two different time stamps as these values get updated automatically in proc/vmstat file by system itself .
We find delta between them , then multiply this delta by pagesize(in kb) and finally divide the result by the time difference.