博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux下查看某个进程占用的CPU、内存
阅读量:4955 次
发布时间:2019-06-12

本文共 3183 字,大约阅读时间需要 10 分钟。

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为内存

转载于:https://www.cnblogs.com/EasonJim/p/8040782.html

你可能感兴趣的文章
程序输入幸运数
查看>>
整数展示分数和整形数的四则运算
查看>>
写入数据java将数据写入到csv文件
查看>>
CI框架源码阅读笔记1 - 环境准备、基本术语和框架流程
查看>>
JSON字符与JSON对象的相互转换
查看>>
QSlider滑块类和QSpinBox微调框类
查看>>
JavaScript学习10 JS数据类型、强制类型转换和对象属性
查看>>
家庭用电的基本知识(转载)
查看>>
Debugging a SQL Server query with WinDbg
查看>>
Percona Live Conferences (2009-2016)-mysql
查看>>
http://bbs.chinaunix.net/thread-169061-1-1.html
查看>>
CenOS搭建FTP服务器
查看>>
1. Two Sum
查看>>
Head First HTML5 Chapter 5 地理定位 Google Maps API Marker 地图上的大头针
查看>>
bootstrap学习地址2017.6.1
查看>>
项目名报错,但是项目里不显示错误的问题
查看>>
Java中的多线程
查看>>
javascript解决小数的加减乘除精度丢失的方案
查看>>
jquery的html,val,text,attr方法
查看>>
重建二叉树(四)
查看>>