0
down vote
favorite


I want to capture the Pagefault values in Ubuntu.

Below is my code logic to capture Pagefaults :

(vm_event_states.event[PGFAULT]);

But when I run the following commands there is a huge difference in the values :

db@ubuntu:~/pgfault$ grep pgfault /proc/vmstat
pgfault 4648883
db@ubuntu:~/pgfault$ cat /proc/pgfault
2358120
db@ubuntu:~/pgfault$ grep pgfault /proc/vmstat
pgfault 4649312
db@ubuntu:~/pgfault$ grep pgfault /proc/vmstat
pgfault 4649663
db@ubuntu:~/pgfault$ cat /proc/pgfault
2291317
student@ubuntu:~/pgfault$ grep pgfault /proc/vmstat
pgfault 4650279

Can someone please help me to understand why there is such a huge difference in the values of pagefaults? Or is there something I missed in the logic of calculation.

I also tried for the "major fault" and the "minor fault" but it didn't work.

Please suggest.