[Troubleshooting] How to troubleshoot 100% CPU usage

The online background alarm CPUis occupied 100%, CPUand the usage is too high. This article introduces how to troubleshoot CPUthe cause of the high usage.

Step 1. top

Enter topthe command to find CPUthe process with the highest occupancy. Shift+PSort by key

It can be seen CPUthat the highest occupancy pidis 92129.

Step 2. top -Hp pid

View the thread information in the specified process, which pidis the first step pid.

top -Hp 92129

pidFind the thread with the highest occupancy 92156, and then convert it to 十六进制, using the formula to convert:

printf '%x' 92156

The output is:167fc

Step 3. jstack command

Use jstackthe command to analyze the process status. In order to facilitate the query, the analysis results are input into a file, jstack pid > x.txtwhere pidis 步骤1the process number.

jstack 92129 > x.txt

Open the file and query the converted hexadecimal number x.txtin the file :步骤2

Find the non- Jdkcode, which is also the code you wrote, and you can find the root of the problem.

Summarize

  • topfind the process number
  • top -HpProcess number, find the thread number, and convert the thread into hexadecimal.
  • jstack pidanalyze. According to the hexadecimal query, find the location of the problem code.

Guess you like

Origin blog.csdn.net/gongzi_9/article/details/126985728