Taking thread/heap dump of running server/process


2. After extracting the jdk , run the following command to take the dump 
/bin/jmap -dump:format=b,file=./heapdump PID

3. To take only thread dump
./bin/jstack -l PID 
./bin/jstack -l PID > /tmp/thread_dump.txt


Following linux commands can be used for digging 

awk '/State: B/ { print }' < /tmp/thread_dump.txt  | sort | uniq -c
awk '/State: WAITING/ { getline; print }' < /tmp/thread_dump.txt | sort | uniq -c