When a Linux system is occupied by one process, it cannot handle requests from other processes. The remaining requests waiting to be processed must wait until the CPU is idle. This time, the system will become very slow. The following commands will help you to identify CPU utilization to resolve CPU-related issues.
Identifying CPU utilization is an important task. The Linux system comes with a variety of tools that report CPU utilization. Using these tools, you will be able to pinpoint:
*CPU Utilization
* shows the utilization of each CPU
* Understand the average utilization of the system CPU
* Intuitive to find which process is eating CPU
#1: Top
The top program provides a dynamic, real-time, and intuitive running system. It displays the main information of the system and displays the list of tasks managed by the kernel. The top command monitors CPU utilization, process state, and memory utilization. The top area contains information about the entire system state, from left to right, top to bottom, and in turn: Current time, uptime, load balancing, total number of processes and overview, CPU status, memory usage, swap occupancy .
Input: Top
Output:
From the CPU state that line, you can clearly grasp the CPU utilization: User mode (US), System mode (SY), Low priority user mode (NI), idle task (ID), I/O Waiting (WA). The top command can also detail how much CPU and how much memory each process consumes.
< Span style= "padding:0px; margin:0px; Background-color:rgb (255, 250, 250); " > #2: Mpstat
The Mpstat command writes each available processor to the standard output, the first processor number is 0, and the full average of all processors is reported once. By default, only the full average is output. To see the situation of each CPU, you need to increase the parameters.
Input: Mpstat
Output:
Input: Mpstat-p All
Output:
#3: SAR
Use the SAR command to collect, report, and save system activity information. The SAR command writes the CPU activity of the day to the standard output. The default recording interval is 10 minutes, and you can also add parameters to specify that the SAR needs to collect data.
Input: SAR
Output:
#4: PS
PS is a very full-featured command. By using the PS command, you can see exactly which process is eating the CPU. The more CPU that's in front of you
Input: Ps-eo Pcpu,pid,user,args | Sort-k 1-r | Head-16
Output:
#5: Gnome-system-monitor
If you have a Linux desktop system installed on your computer, you can use the System Monitor for the graphical interface. From System Monitor, you can visually see the status of the process, CPU and memory consumed, and so on.
How to view Linux system CPU utilization