August 29, 2012

Cloud Computing, Enterprise Cloud Technology 2 min read

How To Check CPU Utilisation On A Linux System with Multiple CPUs

CPUs are like the brains of a computer, and a Linux-based system is no different. If a Linux system is busy with a process, it can’t process other requests. In the end, these requests will have to wait until the CPU is available. This situation becomes a bottleneck, and needs to be optimized. You can fix CPU-related performance issues by determining CPU utilization. In Linux, there are many utilities that can help you on this matter. Some of these utilities can display the utilization of each CPU, identifying those processes that are currently using the CPU, or finding out your system’s average CPU utilization since the last reboot.

The “top” command - find out Linux CPU load

A dynamic, real-time view of a system can be rendered by the top program. The command shows you your system summary information and a list of running tasks. The top command also supervises the memory and CPU utilization, and displays information regarding the overall system status, such as process counts, uptime, CPU status, load average and utilization for memory and swap space.

Linux CPU usage can be found under CPU stats. A task is defined as part of the elapsed CPU time, since the last screen update, expressed in percents of total CPU time. When dealing with multiple CPUs, the top command will display the total number of CPUs. To exit the top command’s display, press q or esc.

The order in which the top command shows processes is by the percentage of CPU utilization. This command shows not just how much memory and processing power is being used, but also information about the current processes.

The “mpstat” command - find out Linux individual CPU load

To find Linux CPU utilization using mpstat and as well as other tools, you need to install an application called sysstat, which includes system performance tools for Linux.
To display the usage of each CPU individually, while using multiple CPUs, use mpstat. This command reports statistics related to processors. For example, it displays activities for every available processor, starting with processor 0.

The “sar” command – report Linux CPU utilization

The current day’s CPU activity can be displayed with the sar command. In standard output, the sar command reports the contents of selected cumulative activity counters in Linux. With this command you can display a comparison of CPU utilization. For example, if you want to compare CPU utilization every 5 seconds for 10 times, use this command: # sar -u 5 10

[template id="7325"]

Skip to section