-1

I would very much like to know the names and locations of the files from which vmstat command information comes from in Linux OS.

Leo1989
  • 23
  • 3

1 Answers1

0

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
[...]
Rachid K.
  • 4,490
  • 3
  • 11
  • 30