Linux下查看某个进程占⽤的CPU、内存
1、⽤top命令指定固定的PID
top -p 10997
查询指定进程的PID
ps -ef | grep zookeeper
jim      10997  1959  0 12⽉14 pts/2  00:00:01 /usr/lib/jvm/java-8-oracle/bin/java -Dzookeeper.log.dir=. -logger=INFO,CONSOLE -cp /home/jim/opt/zookeeper-3.4.9/bin/../build/classes:/home/jim/opt/zookeeper-3.4.9/bin/../build/lib/ 2、使⽤ps查询指定进程名或者PID的占⽤情况
grep命令查看进程ps -aux | grep zookeeper
ps -aux | grep 2181
jim      109970.00.1 11522940 65176 pts/2  Sl  12⽉14  0:01 /usr/lib/jvm/java-8-oracle/bin/java -Dzooke
eper.log.dir=. -logger=INFO,CONSOLE -cp /home/jim/opt/zookeeper-3.4.9/bin/../build/classes:/home/jim/opt/zookeeper-3 10997为PID
0.0为CPU占⽤百分⽐(注意:如果有两个CPU,32核64线程,那么总占⽐是6400%)
0.1为内存占⽤百分⽐
3、查看更详细的内存占⽐
cat /proc/10997/status
Name:    java
State:    S (sleeping)
Tgid:    10997
Ngid:    0
Pid:    10997
PPid:    1959
TracerPid:    0
Uid:    1000    1000    1000    1000
Gid:    1000    1000    1000    1000
FDSize:    256
Groups:    4 24 27 30 46 113 128 130 132 134 **** ****
NStgid:    10997
NSpid:    10997
NSpgid:    10987
NSsid:    10914
VmPeak:    11522940 kB
VmSize:    11522940 kB
VmLck:          0 kB
VmPin:          0 kB
VmHWM:      65176 kB
VmRSS:      65176 kB
VmData:    11462972 kB
VmStk:        140 kB
VmExe:          4 kB
VmLib:      17064 kB
VmPTE:        460 kB
VmPMD:          28 kB
VmSwap:          0 kB
HugetlbPages:          0 kB
Threads:    25
SigQ:    0/128292
SigPnd:    0000000000000000
ShdPnd:    0000000000000000
SigBlk:    0000000000000000
SigIgn:    0000000000000003
SigCgt:    2000000181005ccc
CapInh:    0000000000000000
CapPrm:    0000000000000000
CapEff:    0000000000000000
CapBnd:    0000003fffffffff
CapAmb:    0000000000000000
Seccomp:    0
Cpus_allowed:    ff
Cpus_allowed_list:    0-7
Mems_allowed:    00000000,00000001
Mems_allowed_list:    0
voluntary_ctxt_switches:    86
nonvoluntary_ctxt_switches:    2
VmRSS为内存

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。