Which threads are talking to the database?

Often while troubleshooting, I will want to know where the bottleneck is. If I think the database may be the culprit, I will run the following to print those threads that are making database calls…

-bash-4.1$ jstack 20711 | awk '{if ($1 ~ "^\"") {l=1;thread=$1} else if (l == 1 && $0 != "" && $0 ~ "oracle") {l=0;print thread} else if ($0 == "") {l=0}}'
"http-172.28.8.80-10180-29"
"http-172.28.8.80-10180-24"
"http-172.28.8.80-10543-7"
"http-172.28.8.80-10180-14"
"http-172.28.8.80-10180-4"
-bash-4.1$

All this does is print each thread that has “oracle” in at least one call on the stack.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.