0

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?

oshai
  • 109
  • 2

1 Answers1

0

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.

Soham Chakraborty
  • 3,534
  • 16
  • 24