Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a script that will kill my processes when my machine is doing "too much" swapping of process memory from disk to memory.
What is the best way to determine that? I saw top has %wa and iostat has iowait data. vmstat has swap in and swap out.
Can that be used as a metric? What is the best for me? can someone recommend something else?

share|improve this question

Several methods and you have described them yourself.

First, top - see the cpu load and where the load is. If most of the CPU time is burning at %sys, it is some kind of system activity. Check the memory usage also, if most of the memory is in swapped state, then a continuous high cpu %sys means thrashing situation.

Next, vmstat. you know the fields to monitor.

For historical data, use sar. Again, see the column where cpu time is being burnt.

mpstat will also show the cpu usage condition.

To sum up, lots of tools are there and you can easily filter out specific field you need with some awk, cut, sort.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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