Monitor CPU and RAM with a shell script
Posted on 2006-04-09
I want to write a small shell script for Linux red-hat 3.0 that will automatically monitor the CPU usage and memory.
My plan is to put the script in a cron and write to a file the results every X seconds.
In the end I want to perform an average on all results I have.
I know the command 'top' but not quite sure how to extract the data from its output.
What I'm looking for if possible is something like:
CPU X% free
RAM X% free
The script should run while I'm keeping the machine busy so the I'll use the results for performance analsys.