Troubleshooting the reasons why the Linux server CPU continues to surge is inseparable from these steps!
Source: https://blog.51cto.com/u_14249042/9113840
1. Check CPU usage
First check the CPU usage in Linux system. You can check the CPU usage of each process in the current system by entering the top or htop command on the command line. If the CPU usage is greater than 80%, you can consider troubleshooting.
top
2. Check system load
In addition, you can use the uptime command to view the average load of the system.
$uptime
If the system load exceeds 2 times the number of CPU cores, the system can be considered overloaded.
3. Check system resources
High CPU usage may be caused by a process using a large amount of system resources. You can view the resource usage of each process by using the pidstat command.
$ pidstat -p <pid> 1
Where pid is the process ID. The above command will print the resource usage of the process every second, including CPU usage, memory usage, etc.
4. Check the process
If a process is found to have high resource usage, the process needs to be examined further. You can use the strace command to trace the system calls of the process .
$ strace -p <pid>
The above command will output all system calls and return values of the process, which can help us locate specific problems with the process.
5. Check system logs
If none of the above methods find the problem, you can consider checking the system logs, especially the /var/log/messages and /var/log/syslog files. Various system events and error information are recorded in these files.
$ tail -f /var/log/messages /var/log/syslog
The above command can output the latest contents of these files in real time.
6. Check system bottlenecks
If none of the above methods can find the problem, you can use system performance tools to check for system bottlenecks. One of the common performance tools is perf. You can use the perf top command to view the functions that consume the most CPU time on your system.
$ perf top
The above command will output the CPU usage of related functions on the system in real time.
Spring recruitment has begun. If you are not fully prepared, it will be difficult to find a good job in spring recruitment.
I’m sending you a big employment gift package, so you can raid the spring recruitment and find a good job!