how can I tell if there is a cpu trashing on my linux machine – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.
But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, top, swap, iostat, vmstat.
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?
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.