通过 top命令找到cpu过高的PID
代码语言:txt复制top
top - 08:37:41 up 2 days, 23:34, 6 users, load average: 5.17, 5.48, 5.61
Tasks: 16603 total, 1 running, 16600 sleeping, 0 stopped, 2 zombie
%Cpu(s): 5.1 us, 0.9 sy, 0.0 ni, 94.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 52807283 total, 25800396 free, 22069265 used, 49376204 buff/cache
KiB Swap: 13421772 total, 13421772 free, 0 used. 30150979 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND
96442 root 20 0 208.2g 4.9g 43880 S 600.3 1.0 15290:04 java
96302 root 20 0 161.0g 4.1g 43776 S 100.3 0.8 4165:50 java
通过PID找到线程top -H -p 进程PID
代码语言:txt复制top -H -p 进程PID
top -H -p 96442
top - 08:39:39 up 2 days, 23:36, 6 users, load average: 5.95, 5.68, 5.66
Threads: 10892 total, 6 running, 10886 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.0 us, 0.6 sy, 0.0 ni, 94.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 52807283 total, 25800400 free, 22068240 used, 49386436 buff/cache
KiB Swap: 13421772 total, 13421772 free, 0 used. 30152022 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND
110854 root 20 0 208.2g 4.9g 43880 R 99.9 1.0 2381:35 java
113715 root 20 0 208.2g 4.9g 43880 R 99.9 1.0 2289:06 java
74564 root 20 0 208.2g 4.9g 43880 R 99.9 1.0 2224:58 java
3097 root 20 0 208.2g 4.9g 43880 R 99.9 1.0 2233:56 java
14728 root 20 0 208.2g 4.9g 43880 R 99.9 1.0 2353:03 java
123444 root 20 0 208.2g 4.9g 43880 R 99.4 1.0 2287:02 java
将线程转换为16进制
代码语言:txt复制printf '0x%xn' 线程PID
[root@localhost tigersharks]# printf '0x%xn' 74564
0x12344
将16进制转为
代码语言:txt复制jstack 进程PID |grep 16进制线程PID -A 20
jstack 96442 |grep 0x12344 -A 20
root@localhost bin]# ./jstack 40361 |grep 0xb1cd -A 20
"pool-3-thread-1" #204 prio=5 os_prio=0 tid=0x00007fd2e0002000 nid=0xb1cd runnable [0x00007fd3389e8000]
java.lang.Thread.State: RUNNABLE
at java.io.UnixFileSystem.list(Native Method)
at java.io.File.list(File.java:1122)
at java.io.File.listFiles(File.java:1207)
at clamAv.fileScan.ScanMonitor.lambda$startMonitor$1(ScanMonitor.java:275)
at clamAv.fileScan.ScanMonitor$$Lambda$1187/2062054922.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)