Monitoring CPU usage is one of the important tasks in computing. Even though checking out the CPU usage on a Linux system isn’t as straightforward or user-friendly as on Windows, there are still various utilities available for you to use.
Among all the utilities, Top is probably one of the oldest and yet a very effective tool that provides a dynamic real-time view of a running Linux system. Built right in the system, Top displays not only system summary information but also a list of actively running tasks managed by the Linux kernel.
The top section displays the information related to overall system status, uptime, load average, the number of tasks, process count, CPU status, memory and swap space stats.
The bottom section contains a frequently-updated list of processes, ordered by the CPU usage by default.
Alternatively, if you would like to find out which processes is occupying the CPU usage, ps is your friend.
To see the top 10 CPU occupiers on your system, use:
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
The sysstat package
The sysstat is a special package that includes a set of system performance tools for Linux. It’s installed by default on Red Hat but needs to be installed on a Debian or Ubuntu system.
$> sudo apt-get install sysstat
There are a few utilities you may want to check once you have the package installed, including mpstat, iostat, sar, etc.