View the CPU cores of a specified process in CentOS

Source: Internet
Author: User

Multiple multi-core CPUs are now the mainstream servers. Many applications, such as Squid and nginx, have the ability to distribute processes or threads to different CPU cores.

How can we view the distribution of different processes in the CPU core.

Use the top tool and use the pgrep or pidof commands.

For example, to view the distribution of CPU cores in the nginx process:

 
  1. Top-p $ (pgrepnginx | awk 'in in {ORS = ","} {print $0} '| sed's/. $ //')
  2. # Or you can use
  3. # Pidof nginx | sed-e's //,/G'
  4. # To replace
  5. # Pgrepnginx | awk 'in in {ORS = ","} {print $0} '| sed's/. $ //'
  6. # To obtain the formatted pid Value

Press the f key to list the display menu options, press j, and select the CPU core information column. Press enter to return to the top screen.

As follows:

 
  1. Top-14: 46: 21up13: 45, 2 users, loadaverage: 0.00, 0.00, 0.00
  2. Tasks: 5 total, 0 running, 5 sleeping, 0 stopped, 0 zombie
  3. Cpu (s): 0.0% us, 0.1% sy, 0.0% ni, 99.9% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st
  4. Mem: 1026684 ktotal, 887572 kused, 139112 kfree, 135308 kbuffers
  5. Swap: 2064376 ktotal, 0 kused, 2064376 kfree, 603008 kcached
  6. Piduserprni1_resshrs % CPU % MEMTIME + PCOMMAND
  7. 12393root180410001428808S0. 00.10: 00.001 nginx
  8. 12625nginx150413441440536S0. 00.10: 00.000 nginx
  9. 12626nginx150413441592688S0. 00.20: 00.001 nginx
  10. 12627nginx150413441440536S0. 00.10: 00.002 nginx
  11. 12628nginx150413441440536S0. 00.10: 00.003 nginx

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.