查看Linux进程CPU过高具体的线程堆栈(不中断程序)
转自:http://blog.csdn.net/mergerly/article/details/47731305
1、TOP命令,找到占用CPU最高的进程
- $ top
- top - 20:11:45 up 850 days, 1:18, 3 users, load average: 1.04, 1.01, 0.99
- Tasks: 61 total, 1 running, 60 sleeping, 0 stopped, 0 zombie
- Cpu(s): 1.4% us, 0.1% sy, 0.0% ni, 98.3% id, 0.1% wa, 0.0% hi, 0.2% si
- Mem: 16418172k total, 15693376k used, 724796k free, 1146696k buffers
- Swap: 10223608k total, 0k used, 10223608k free, 12537692k cached
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
- 24714 ztgame 16 0 1409m 1.2g 4252 S 99.6 7.4 2390:57 IMVChannelServe
- 1 root 16 0 4772 520 432 S 0.0 0.0 0:03.43 init
- 2 root RT 0 0 0 0 S 0.0 0.0 0:05.75 migration/0
- 3 root 34 19 0 0 0 S 0.0 0.0 5:22.97 ksoftirqd/0
- 4 root RT 0 0 0 0 S 0.0 0.0 0:07.90 migration/1
- 5 root 34 19 0 0 0 S 0.0 0.0 0:00.27 ksoftirqd/1
- 6 root RT 0 0 0 0 S 0.0 0.0 0:04.07 migration/2
- 7 root 34 19 0 0 0 S 0.0 0.0 0:00.47 ksoftirqd/2
- 8 root RT 0 0 0 0 S 0.0 0.0 0:04.00 migration/3
- 9 root 34 19 0 0 0 S 0.0 0.0 0:00.33 ksoftirqd/3
2、通过TOP -H -p 进程ID,找到具体的线程占用情况,Shift+H可以开启关闭线程显示
- $ top -H -p 24714
- top - 20:15:30 up 850 days, 1:22, 3 users, load average: 1.26, 1.09, 1.02
- Tasks: 16 total, 1 running, 15 sleeping, 0 stopped, 0 zombie
- Cpu(s): 24.8% us, 0.3% sy, 0.0% ni, 73.1% id, 0.0% wa, 0.0% hi, 1.8% si
- Mem: 16418172k total, 15701376k used, 716796k free, 1146704k buffers
- Swap: 10223608k total, 0k used, 10223608k free, 12546048k cached
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
- 24729 ztgame 16 0 1409m 1.2g 4252 R 97.0 7.4 2307:22 IMVChannelServe
- 24721 ztgame 15 0 1409m 1.2g 4252 S 2.0 7.4 84:22.40 IMVChannelServe
- 24714 ztgame 16 0 1409m 1.2g 4252 S 0.0 7.4 0:03.80 IMVChannelServe
- 24716 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 IMVChannelServe
- 24717 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.04 IMVChannelServe
- 24718 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 IMVChannelServe
- 24719 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.08 IMVChannelServe
- 24720 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.01 IMVChannelServe
- 24722 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 IMVChannelServe
- 24723 ztgame 16 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 IMVChannelServe
- 24724 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.01 IMVChannelServe
- 24725 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:09.83 IMVChannelServe
- 24726 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.00 IMVChannelServe
- 24727 ztgame 15 0 1409m 1.2g 4252 S 0.0 7.4 0:00.76 IMVChannelServe
- 24728 ztgame 16 0 1409m 1.2g 4252 S 0.0 7.4 0:00.53 IMVChannelServe
- 24730 ztgame 16 0 1409m 1.2g 4252 S 0.0 7.4 2:42.18 IMVChannelServe
3、通过命令pstack 进程ID显示线程堆栈,LWP 24729对应线程ID的堆栈,就是占用CPU最高的堆栈,可以具体分析什么原因造成的。
- $ pstack 24714
- Thread 16 (Thread 1084229984 (LWP 24716)):
- #0 0x00000039c5a901d5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
- #1 0x00000039c5ac3058 in usleep () from /lib64/tls/libc.so.6
- #2 0x00000000005ebe10 in zVerifyThread::run ()
- #3 0x00000000005e9d29 in zThread::threadFunc ()
- #4 0x00000039c6106137 in start_thread () from /lib64/tls/libpthread.so.0
- #5 0x00000039c5ac9883 in clone () from /lib64/tls/libc.so.6
- Thread 15 (Thread 1094719840 (LWP 24717)):
- #0 0x00000039c5a901d5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
- #1 0x00000039c5ac3058 in usleep () from /lib64/tls/libc.so.6
- #2 0x00000000005ebe10 in zVerifyThread::run ()
- #3 0x00000000005e9d29 in zThread::threadFunc ()
- #4 0x00000039c6106137 in start_thread () from /lib64/tls/libpthread.so.0
- #5 0x00000039c5ac9883 in clone () from /lib64/tls/libc.so.6
- Thread 14 (Thread 1105209696 (LWP 24718)):
- #0 0x00000039c5a901d5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
- #1 0x00000039c5ac3058 in usleep () from /lib64/tls/libc.so.6
- #2 0x00000000005ebe10 in zVerifyThread::run ()
- #3 0x00000000005e9d29 in zThread::threadFunc ()
- #4 0x00000039c6106137 in start_thread () from /lib64/tls/libpthread.so.0
- #5 0x00000039c5ac9883 in clone () from /lib64/tls/libc.so.6
- Thread 13 (Thread 1115699552 (LWP 24719)):
- #0 0x00000039c5a901d5 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
- #1 0x00000039c5ac3058 in usleep () from /lib64/tls/libc.so.6
- #2 0x00000000005ebe10 in zVerifyThread::run ()
- #3 0x00000000005e9d29 in zThread::threadFunc ()
- #4 0x00000039c6106137 in start_thread () from /lib64/tls/libpthread.so.0
- #5 0x00000039c5ac9883 in clone () from /lib64/tls/libc.so.6
- Thread 3 (Thread 1220598112 (LWP 24729)):
- #0 0x00000039c5a71e87 in memset () from /lib64/tls/libc.so.6
- #1 0x00000000004fa591 in ChannelTask::forwardToClientByMedia ()
- #2 0x0000000000506220 in ChannelTask::parseClientMsg_Normal ()
- #3 0x000000000051ef55 in ChannelTask::parseClientMsg ()
- #4 0x000000000051f070 in ChannelTask::cmdMsgParse_Forward ()
- #5 0x000000000051f1d1 in ChannelTask::cmdMsgParse ()
- #6 0x000000000051f414 in ChannelTask::processCmd ()
- #7 0x0000000000523ea8 in ChannelTaskManager::processCmd ()
- #8 0x0000000000525ddd in ChannelTimeTick::run ()
- #9 0x00000000005e9d29 in zThread::threadFunc ()
- #10 0x00000039c6106137 in start_thread () from /lib64/tls/libpthread.so.0
- #11 0x00000039c5ac9883 in clone () from /lib64/tls/libc.so.6
- Thread 2 (Thread 1231087968 (LWP 24730)):
- #0 0x00000039c610af8b in __lll_mutex_lock_wait ()
- #1 0x0000000000000001 in ?? ()
- #2 0x0000000000000065 in ?? ()
- #3 0x00000039c6107d87 in pthread_mutex_lock () from /lib64/tls/libpthread.so.0
- #4 0x0000003a500ae29e in operator delete () from /usr/lib64/libstdc++.so.6
- #5 0x000000000053f59d in ChannelLoadClient::processCmd_DB ()
- #6 0x00000000005986c9 in GameAppClient::processTaskCmd_DB ()
- #7 0x00000039c5a901e3 in __nanosleep_nocancel () from /lib64/tls/libc.so.6
- #8 0x0000000000000000 in ?? ()
- Thread 1 (Thread 182894183104 (LWP 24714)):
- #0 0x00000039c5ac9c5c in epoll_wait () from /lib64/tls/libc.so.6
- #1 0x0000000000620cac in zTCPServer::accept ()
- #2 0x00000000005f9c0d in zNetService::serviceCallback ()
- #3 0x00000000005f89e3 in zService::main ()
- #4 0x0000000000564298 in main ()
查看Linux进程CPU过高具体的线程堆栈(不中断程序)的更多相关文章
- 【转载】查看Linux进程CPU过高具体的线程堆栈(不中断程序)
具体的命令经常忘记,毕竟用的不是很多.为了避免去找备份一下 1.TOP命令,找到占用CPU最高的进程 $ top top - 20:11:45 up 850 days, 1:18, 3 users ...
- linux ps命令,查看某进程cpu和内存占用率情况, linux ps命令,查看进程cpu和内存占用率排序。 不指定
背景:有时需要单看某个进程的CPU及占用情况,有时需要看整体进程的一个占用情况.一. linux ps命令,查看某进程cpu和内存占用率情况[root@test vhost]# ps auxUSER ...
- Java进程CPU使用率高排查
Java进程CPU使用率高排查 生产java应用,CPU使用率一直很高,经常达到100%,通过以下步骤完美解决,分享一下.1.jps 获取Java进程的PID.2.jstack pid >> ...
- 查看linux服务器CPU相关
查看linux服务器CPU相关: 1.查看物理CPU个数 cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l 2.查看 ...
- 查看Linux服务器CPU总核数
下面介绍查看Linux服务器CPU总核数的方法. 通过/proc/cpuinfo可查看CPU个数及总核数. [root@kevin ~]# grep processor /proc/cpuinfo | ...
- linux查看某个进程CPU消耗较高的具体线程或程序的方法
目前我们的监控,可以发现消耗较高CPU的进程(阀值为3个CPU),通过监控我们可以找到消耗较高CPU的进程号: 通过进程号pid,我们在linux上可以通过top –H –p <pid> ...
- java进程CPU飙高
因为这段时间一直在弄监控,但是工作还是在进行中 因为机器不多,所以今天早上巡检了一下,看到一台生产机器上的CPU飙高 top
- JVM进程cpu飙高分析
在项目快速迭代中版本发布频繁 近期上线报错一个JVM导致服务器cpu飙高 但内存充足的原因现象. 对于耗内存的JVM程序来而言, 基本可以断定是线程僵死(死锁.死循环等)问题. 这里是纪录一下排 ...
- JVM 之 Linux定位CPU过高问题及优化
项目部署以后出行卡顿现象,所以对问题进行了排查,记录一下排查过程 (从CSDN编辑器贴过来的,图有水印) 1.找进程 top 可以发现,是Java进程导致的CPU过高,致使系统卡顿 2.找线程 ps ...
随机推荐
- Coursera台大机器学习技法课程笔记11-Gradient Boosted Decision Tree
将Adaboost和decision tree相结合,需要注意的地主是,训练时adaboost需要改变资料的权重,如何将有权重的资 料和decision tree相结合呢?方法很类似于前面讲过的bag ...
- MongoDB学习笔记-1
mongod --dbpath D:\MogonDB3.4.10\db //开启数据库,无端口号mongod --dbpath D:\MogonDB3.4.10\db --port=10086 //开 ...
- kaldi 三个脚本cmd.sh path.sh run.sh
参考 kaldi 的全部资料_v0.4 cmd.sh 脚本为: 可以很清楚的看到有 3 个分类分别对应 a,b,c.a 和 b 都是集群上去运行这个样子, c 就是我们需要的.我们在虚拟机上运行的 ...
- mysql xtrabackup工具备份
一.注意事项 建议用xtrabackup备份时采用全备或增量备份的方式,楼主也尝试过单库备份,但是都以备份后恢复到已经存在数据库的mysqldata目录下后部分库会出幺蛾子而告终,建议使用mysqld ...
- PHP内置函数实现简单洗牌
function wash_card($num_card) { $a = array_keys(array_fill(0, $num_card, '')); $b = array_keys(array ...
- All Friends 极大团
搞懂了什么是团 什么是极大团 什么是最大团 极大团就是 不是任何团的真子集 最大团就是点数最多的极大团 这题就是求极大团的个数 用bk算法 #include <iostream> ...
- Python3.7.2,在Linux上跑来跑去的,是在升级打怪么?
Python3.7.2,在Linux上跑来跑去的,是在升级打怪么? 前不久,发布了Python在Windows(程序员:Python学不学?完全没必要纠结)和Mac OS(我是Python,P派第 ...
- 干货: 可视化项目实战经验分享,轻松玩转 Bokeh (建议收藏)
作者 | Will Koehrsen 翻译 | Lemon 译文出品 | Python数据之道 (ID:PyDataRoad) 本文通过一个项目案例,详细的介绍了如何从 Bokeh 基础到构建 Bok ...
- Codeforces Round #258 (Div. 2) . Sort the Array 贪心
B. Sort the Array 题目连接: http://codeforces.com/contest/451/problem/B Description Being a programmer, ...
- UVALive 6889 City Park 并查集
City Park 题目连接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=122283#problem/F Description P ...