Issue
I would very much like to know the names and locations of the files from which vmstat
command information comes from in Linux OS.
id='dv3'>
Solution
User space tools reporting statistics likely get them from the kernel through procfs/sysfs file systems. As most of them are open sources, it is easy to read the source code. For example, a way to get the package name it comes from is to display the version:
$ vmstat --version
vmstat from procps-ng 3.3.16
From the preceding, you know that you can grab the source code from procps-ng package.
And as said in the comments by Stark, you can spy the execution of vmstat
with strace
tool and you will see which files are opened to get the information:
$ strace vmstat
[...]
openat(AT_FDCWD, "/proc/meminfo", O_RDONLY) = 3
[...]
openat(AT_FDCWD, "/proc/stat", O_RDONLY) = 4
[...]
openat(AT_FDCWD, "/proc/vmstat", O_RDONLY) = 5
[...]
Answered By - Rachid K. Answer Checked By - Marilyn (WPSolving Volunteer)