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. Here we use the top tool and use the pgrep or pidof command to view the distribution of CPU cores in the nginx process, for example, top-p $ (pgrepnginx
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:
- Top-p $ (pgrep nginx | awk 'In in {ORS = ","} {print $0} '| sed's/. $ //')
- # Or you can use
- # Pidof nginx | sed-e's //,/g'
- # To replace
- # Pgrep nginx | awk 'In in {ORS = ","} {print $0} '| sed's/. $ //'
- # 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:
- Top-14:46:21 up, 2 users, load average: 0.00, 0.00, 0.00
- Tasks: 5 total, 0 running, 5 sleeping, 0 stopped, 0 zombie
- 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
- Mem: 1026684 k total, 887572 k used, 139112 k free, 135308 k buffers
- Swap: 2064376 k total, 0 k used, 2064376 k free, 603008 k cached
-
- Pid user pr ni virt res shr s % CPU % mem time + P COMMAND
- 12393 root 18 0 41000 1428 808 S 0.0 0: 00. 00 1 nginx
- 12625 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 0 nginx
- 12626 nginx 15 0 41344 1592 688 S 0.0 0: 00. 00 1 nginx
- 12627 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 2 nginx
- 12628 nginx 15 0 41344 1440 536 S 0.0 0: 00. 00 3 nginx