cpu暴涨如何分析
top
首先,top找一下最占用系统资源的进程
ps -mp
[root@hecs-82454 ~]# ps -mp 1376 -o THREAD,tid,time
USER %CPU PRI SCNT WCHAN USER SYSTEM TID TIME
root 0.2 - - - - - - 00:00:00
root 0.0 19 - futex_ - - 1376 00:00:00
root 0.1 19 - futex_ - - 1377 00:00:00
root 0.0 19 - futex_ - - 1378 00:00:00
root 0.0 19 - futex_ - - 1379 00:00:00
root 0.0 19 - futex_ - - 1380 00:00:00
root 0.0 19 - futex_ - - 1381 00:00:00
root 0.0 19 - futex_ - - 1382 00:00:00
root 0.0 19 - futex_ - - 1383 00:00:00
root 0.0 19 - futex_ - - 1384 00:00:00
root 0.0 19 - futex_ - - 1385 00:00:00
tid转换
找到占用最大的tid,就是线程号,但是这个线程需要换成16进制的
[root@hecs-82454 ~]# printf "%x\n" 1377
561
jstack打印
[root@hecs-82454 ~]# jstack 1376 |grep 561
"main" #1 prio=5 os_prio=0 tid=0x00007f34c0009800 nid=0x561 waiting on condition [0x00007f34c8c6f000]
这里只是个例子,如果线上的话会打印出很多东西,在打印出来的内容里找到自己熟悉的代码