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?


"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.

| improve this answer | |
  • perfect. I should have searched for vmstat. Thanks! – randomx Oct 23 '09 at 2:51

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.

| improve this answer | |

Another useful tool is atop, which gives more detailed views of I/O than plain old top.

| improve this answer | |

Have you gone thru the manpage?

man vmstat

If you need historical information, I use kSar. It has the additional useful ability that it can be run on a remote machine and gather information directly via ssh.

| improve this answer | |

One of the great linux dilemmas is knowing which tool to use. I guess that's one of the reasons I wrote collectl over 5 years ago. It combines the best of most other tools to combine just about all other them into one. In fact, it provides alternate formats of output so if you like vmstat output you just run "collectl --vmstat". So why not just run vmstat? Thats easy - collectl can also record data like sar but play it back to look like vmstat! It will even play it back in a format which you can directly feed to gnuplot (see collectl-utils) or you can load it into exel or even RRD if you want to go that route.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.