How do I measure disk thrashing on linux?

How do I accurately observe and measure the amount of virtual memory utilization and activity on Linux? I know there is vmstat, but how do I interpret the results? Or, what is better?


Solution 1:

"vmstat" will tell you what you want to know. The "si" and "so" columns are showing you the amount of memory swapped in / out per interval. Both "vmstat" and "free" can show you the breakdown of memory usage. Rather than copy and paste the text, my answer here gives you some background into what those tools report.

Solution 2:

If the thrashing is caused by swapping then this line gives a good number:

vmstat 10 2 | tail -n1 | awk  '{print $7*$8}'

If the computer is swapping out, it may be OK. If the computer is swapping in, that may be OK, too. But if the computer is both swapping in and swapping out then it is bad.