I have a Ubuntu server running in EC2.
Occasionally, I get a large CPU usage 99+% utilization as measured in EC2 monitoring dashboard, even though most times it is less than 10%.
Since traffic to my site is spiky, and many times happens at the middle of the night, I could not login and use top at that time.
What is the best way to monitor which processes is using the CPU when the load spikes up?
One option I can think of is, dump top output every few seconds to a file.
However, is there a better option to monitor CPU and memory hungry processes?