I've created a few light monitoring scripts for a server I've set up.
One of the scripts tests for sustained high CPU load, and has been sending notices once a day in the middle of the night. But the alerts have been sent at different times each nigh, so the CPU load doesn't seem to be related to any of the regular cron jobs I have set up.
I know I can use top to view CPU usage breakdown in realtime, but is there any tool I can use in a bash script that would report what apps are using the most CPU % at a given moment in time?
ps -rf?man psis your friend.