Find out the CPU consumption of each thread in the process

Source: Internet
Author: User

Execute the following command with the root user, using PID 5423 for example:

1, according to the top command, to find high CPU-intensive processes, to find the PID
PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
5423 Root 0 8892 1284 856 R 0 0.0 0:00.04 Top

2, after the process is found, execute the following command to get the list of threads and sort by the thread that is consuming high CPU:
[Email protected]]# ps-mp 5423-o Thread,tid,time | Sort-rn

The results are shown as follows (example):
User%cpu PRI SCNT wchan user SYSTEM TID time
Root 10.5 19----3626 00:12:48
Root 10.1 19----3593 00:12:16

Found the most time-consuming thread 3626, taking up CPU time for 12 minutes!

3, convert the required thread ID to 16 binary format:
[[email protected] logs]# printf "%x\n" 3626
E18

4, the last print thread's stack information:
[[email protected]]# sudo-u start username jstack 5423 > Stack.log

Find out the CPU consumption of each thread in the process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.