Debian系列通过top查看进程绑定的CPU_ID

debian系列与rhel系列有些地方差别还是挺大的,rhel里直接top,f,j,回车,即可看到所有进程所在的cpu id,ubuntu里找了找,也是可以做到的

 

当然如果不想用top来看,通过ps命令也是可以找的

lihui@2015-vm1:~$ pgrep mysql
2209


lihui@2015-vm1:~$ ps -eo pid,psr | grep 2209
  2209   1

 

如果直接看top,可以进行如下操作
top

top - 23:01:35 up 1 min,  1 user,  load average: 0.22, 0.10, 0.04
Tasks: 465 total,   2 running, 463 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.2 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   3947716 total,   568272 used,  3379444 free,    37760 buffers
KiB Swap:        0 total,        0 used,        0 free.   232172 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                 
   283 root      39  19       0      0      0 S   0.7  0.0   0:00.06 khugepaged                                                                              
   318 root      20   0       0      0      0 S   0.3  0.0   0:00.32 kworker/1:1                                                                             
   477 root      20   0       0      0      0 S   0.3  0.0   0:00.12 kworker/u256:29                                                                         
  1280 root      10 -10   20940    420     48 S   0.3  0.0   0:00.11 monitor                                                                                 
  1291 root      10 -10  169904  24356   6408 S   0.3  0.6   0:00.31 ovs-vswitchd                                                                            
  2327 rabbitmq  20   0 1638380  45132   4056 S   0.3  1.1   0:05.41 beam.smp                                                                                
  2844 lihui     20   0   23940   3192   2392 R   0.3  0.1   0:00.02 top                                                                                     
     1 root      20   0   33792   4308   2632 S   0.0  0.1   0:03.03 init                                                                                    
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.07 kthreadd                                                                                
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.08 ksoftirqd/0                                                                             
     4 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0                                                                             
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                            
     6 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kworker/u256:0                                                                          
     7 root      20   0       0      0      0 R   0.0  0.0   0:00.65 rcu_sched                                                                               

f

* PID     = Process Id             CGROUPS = Control Groups      
* USER    = Effective User Name    SUPGIDS = Supp Groups IDs     
* PR      = Priority               SUPGRPS = Supp Groups Names   
* NI      = Nice Value             TGID    = Thread Group Id     
* VIRT    = Virtual Image (KiB)    ENVIRON = Environment vars    
* RES     = Resident Size (KiB)    vMj     = Major Faults delta  
* SHR     = Shared Memory (KiB)    vMn     = Minor Faults delta  
* S       = Process Status         USED    = Res+Swap Size (KiB) 
* %CPU    = CPU Usage              nsIPC   = IPC namespace Inode 
* %MEM    = Memory Usage (RES)     nsMNT   = MNT namespace Inode 
* TIME+   = CPU Time, hundredths   nsNET   = NET namespace Inode 
* COMMAND = Command Name/Line      nsPID   = PID namespace Inode 
  PPID    = Parent Process pid     nsUSER  = USER namespace Inode
  UID     = Effective User Id      nsUTS   = UTS namespace Inode 
  RUID    = Real User Id        
  RUSER   = Real User Name      
  SUID    = Saved User Id       
  SUSER   = Saved User Name     
  GID     = Group Id            
  GROUP   = Group Name          
  PGRP    = Process Group Id    
  TTY     = Controlling Tty     
  TPGID   = Tty Process Grp Id  
  SID     = Session Id          
  nTH     = Number of Threads   
  P       = Last Used Cpu (SMP) 
  TIME    = CPU Time            
  SWAP    = Swapped Size (KiB)  
  CODE    = Code Size (KiB)     
  DATA    = Data+Stack (KiB)    
  nMaj    = Major Page Faults   
  nMin    = Minor Page Faults   
  nDRT    = Dirty Pages Count   
  WCHAN   = Sleeping in Function
  Flags   = Task Flags <sched.h>

看到了P       = Last Used Cpu (SMP) 这行,光标移到这里,然后回车或者d

* PID     = Process Id             CGROUPS = Control Groups      
* USER    = Effective User Name    SUPGIDS = Supp Groups IDs     
* PR      = Priority               SUPGRPS = Supp Groups Names   
* NI      = Nice Value             TGID    = Thread Group Id     
* VIRT    = Virtual Image (KiB)    ENVIRON = Environment vars    
* RES     = Resident Size (KiB)    vMj     = Major Faults delta  
* SHR     = Shared Memory (KiB)    vMn     = Minor Faults delta  
* S       = Process Status         USED    = Res+Swap Size (KiB) 
* %CPU    = CPU Usage              nsIPC   = IPC namespace Inode 
* %MEM    = Memory Usage (RES)     nsMNT   = MNT namespace Inode 
* TIME+   = CPU Time, hundredths   nsNET   = NET namespace Inode 
* COMMAND = Command Name/Line      nsPID   = PID namespace Inode 
  PPID    = Parent Process pid     nsUSER  = USER namespace Inode
  UID     = Effective User Id      nsUTS   = UTS namespace Inode 
  RUID    = Real User Id        
  RUSER   = Real User Name      
  SUID    = Saved User Id       
  SUSER   = Saved User Name     
  GID     = Group Id            
  GROUP   = Group Name          
  PGRP    = Process Group Id    
  TTY     = Controlling Tty     
  TPGID   = Tty Process Grp Id  
  SID     = Session Id          
  nTH     = Number of Threads   
* P       = Last Used Cpu (SMP) 
  TIME    = CPU Time            
  SWAP    = Swapped Size (KiB)  
  CODE    = Code Size (KiB)     
  DATA    = Data+Stack (KiB)    
  nMaj    = Major Page Faults   
  nMin    = Minor Page Faults   
  nDRT    = Dirty Pages Count   
  WCHAN   = Sleeping in Function
  Flags   = Task Flags <sched.h>

q保存退出,就会在屏幕的最右边看到P那列的数字,就是cpu的core id

Tasks: 504 total,   2 running, 502 sleeping,   0 stopped,   0 zombie
%Cpu0  : 24.7 us,  8.4 sy,  0.0 ni, 66.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  : 30.8 us, 10.8 sy,  0.0 ni, 58.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu2  : 31.2 us,  8.5 sy,  0.0 ni, 60.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   3947716 total,  1973232 used,  1974484 free,    42020 buffers
KiB Swap:        0 total,        0 used,        0 free.   281624 cached Mem

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                P
  3527 root      20   0  227308  65716   8816 S   8.3  1.7   0:39.65 python                                                                                 0
  3520 root      20   0  114456  43288   7768 S   3.5  1.1   0:11.01 python                                                                                 2
 16836 root      20   0   42124  13780   6636 R   1.6  0.3   0:00.04 neutron-rootwra                                                                        2
     9 root      20   0       0      0      0 S   1.2  0.0   0:02.82 rcuos/1                                                                                0
  3505 root      20   0  118628  44096   9848 S   1.2  1.1   0:04.66 python                                                                                 0
  3511 root      20   0  166892  77848  10080 S   1.2  2.0   0:05.83 nova-api                                                                               0
  3522 root      20   0  137232  52568   9820 S   1.2  1.3   0:04.97 python                                                                                 0
     7 root      20   0       0      0      0 S   0.8  0.0   0:03.75 rcu_sched                                                                              0
     8 root      20   0       0      0      0 S   0.8  0.0   0:02.91 rcuos/0                                                                                1
    10 root      20   0       0      0      0 S   0.8  0.0   0:03.16 rcuos/2                                                                                1
   820 syslog    20   0  255848   4764   2484 S   0.8  0.1   0:01.65 rsyslogd                                                                               2
  1281 root      10 -10   21424   4716   3800 S   0.8  0.1   0:01.48 ovsdb-server                                                                           2
  2327 rabbitmq  20   0 1745196 111588   4056 S   0.8  2.8   0:15.25 beam.smp                                                                               0
  3492 root      20   0   94456  29320   7280 S   0.8  0.7   0:04.32 python                                                                                 0
   265 root      rt   0       0      0      0 S   0.4  0.0   0:00.15 migration/0                                                                            0
   293 root      20   0       0      0      0 S   0.4  0.0   0:02.01 kworker/0:1                                                                            0
  2209 mysql     20   0 1536300  83212  10792 S   0.4  2.1   0:05.28 mysqld                                                                                 1
  2963 root      20   0       0      0      0 S   0.4  0.0   0:00.48 kworker/1:0                                                                            1
  3503 root      20   0  332276  46020   8504 S   0.4  1.2   0:02.59 python                                                                                 2
  3525 root      20   0  114212  42688   7616 S   0.4  1.1   0:01.58 python                                                                                 2
  3529 root      20   0  136948  39740   9848 S   0.4  1.0   0:00.85 nova-novncproxy                                                                        2
 16491 lihui     20   0   23940   3300   2468 R   0.4  0.1   0:00.03 top                                                                                    1
     1 root      20   0   33792   4308   2632 S   0.0  0.1   0:03.12 init                                                                                   1
     2 root      20   0       0      0      0 S   0.0  0.0   0:00.07 kthreadd                                                                               2
     3 root      20   0       0      0      0 S   0.0  0.0   0:00.11 ksoftirqd/0                                                                            0
     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                           0
    11 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/3                                                                                1
    12 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/4                                                                                0
    13 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/5                                                                                0
    14 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/6                                                                                0
    15 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcuos/7                                                                                0

发表回复