cpu high usage of the Linux system analysis method
1, the top command can clearly see which process is consuming a relatively high cpu
2, ps -mp 25147-o THREAD, tid, time \ top -Hp pid find the most time-consuming thread
Or: Use top -H -p <pid> to view the process inside thread occupancy
After the top or use the command: the Shift + H to see which processes drive the highest consumption
3, thread ID need to convert hexadecimal format
,
Print stack information
sudo jstack 25147 | grep 6268
3889 jstack> /tmp/aa.txt , stack all the process information into a temporary file inside aa.txt
to sum up:
1. Find the process
top view process consumes resources
Java is evident that the process of occupation too high cpu.
2. Find threads
Use top -H -p <pid> View Thread occupancy
3. Find a java stack information
To convert to hex thread id
#printf %x 15664
# 3d30
And then use the query thread stack information jstack
Syntax: jstack <pid> | grep -a thread the above mentioned id (hex)
jstack <pid> | grep -a 3d30
This will identify the problematic code.
pid: process id tid: thread id