A variety of useful scripts, mostly here for archival purposes
Scripts for doing surface-level analysis of Java thread dumps as captured by jstack. Both can be used with stdin as well.
-
extract_stacks_by_regex
An awk script that will extract any stack trace in a thread dump where any line contains the passed-in regex.
Usage: awk -f extract_\stacks_by_regex -v regex=regex file
-
summarize_thread_dump
An awk script that will provide a quick summary of a thread dump. It will show number of threads in various states and then summarize the number of threads in each code path by finding the first line in a stack that doesn't have java or sun in it (in other words, the first code likely to be yours or a third-party library you're using) and then aggregating those lines to show the sum.
Usage: awk -f summarize_thread_dump file