how can I tell if there is a cpu trashing on my linux machine

view story

http://serverfault.com – 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? (HowTos)