jstack 打印线程堆栈信息
Prints Java thread stack traces for a Java process, core file, or remote debug server. This command is experimental and unsupported.
一、命令位置
[root@dewan01 ~]# which jstack
/usr/bin/jstack
二、命令语法
SYNOPSIS
jstack [ options ] pid
jstack [ options ] executable core
jstack [ options ] [ server-id@ ] remote-hostname-or-IP
OPTIONS
-l Long listing. Prints additional information about locks such as a list of owned java.util.concurrent ownable synchronizers.
-F Force a stack dump when jstack [-l] pid does not respond.
三、实例
[root@dewan01 zdw]# jps
31125 Jps
22805 Elasticsearch
1097 WrapperSimpleApp
[root@dewan01 zdw]# sudo -u elasticsearch jstack -l 22805 | grep java.lang.Thread.State | wc -l
27
四、其他
[root@dewan01 ~]# ps -eo pid,user,pcpu --sort=-pcpu | head -n 3 ## 查看占cpu高的进程
PID USER %CPU
15534 elastic+ 6.9
15072 root 0.1
[root@dewan01 ~]# lsof -n -p 15534 | wc -l ## 查看进程打开的文件
162
[root@dewan01 ~]# ps -Lp 15534 | wc -l ## 查看某进程的线程数
32