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=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/jim/opt/zookeeper-3.4.9/bin/../build/classes:/home/jim/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/home/jim/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/home/jim/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/jim/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
2、使用ps查询指定进程名或者PID的占用情况
ps -aux | grep zookeeper
ps -aux | grep 2181
jim 10997 0.0 0.1 11522940 65176 pts/2 Sl 12月14 0:01 /usr/lib/jvm/java-8-oracle/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/jim/opt/zookeeper-3.4.9/bin/../build/classes:/home/jim/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/home/jim/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/home/jim/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/jim/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
10997为PID
0.0为CPU占用百分比(注意:如果有两个CPU,32核64线程,那么总占比是6400%)
0.1为内存占用百分比
3、查看更详细的内存占比
cat /proc/10997/status
Name: javaState: S (sleeping)Tgid: 10997Ngid: 0Pid: 10997PPid: 1959TracerPid: 0Uid: 1000 1000 1000 1000Gid: 1000 1000 1000 1000FDSize: 256Groups: 4 24 27 30 46 113 128 130 132 134 1000 1002 NStgid: 10997NSpid: 10997NSpgid: 10987NSsid: 10914VmPeak: 11522940 kBVmSize: 11522940 kBVmLck: 0 kBVmPin: 0 kBVmHWM: 65176 kBVmRSS: 65176 kBVmData: 11462972 kBVmStk: 140 kBVmExe: 4 kBVmLib: 17064 kBVmPTE: 460 kBVmPMD: 28 kBVmSwap: 0 kBHugetlbPages: 0 kBThreads: 25SigQ: 0/128292SigPnd: 0000000000000000ShdPnd: 0000000000000000SigBlk: 0000000000000000SigIgn: 0000000000000003SigCgt: 2000000181005cccCapInh: 0000000000000000CapPrm: 0000000000000000CapEff: 0000000000000000CapBnd: 0000003fffffffffCapAmb: 0000000000000000Seccomp: 0Cpus_allowed: ffCpus_allowed_list: 0-7Mems_allowed: 00000000,00000001Mems_allowed_list: 0voluntary_ctxt_switches: 86nonvoluntary_ctxt_switches: 2
VmRSS为内存