Skip to content

Instantly share code, notes, and snippets.

@kokosing
Created May 31, 2018 10:04
Show Gist options
  • Save kokosing/8f60122f74c355b1aaa0d1d2aa194e02 to your computer and use it in GitHub Desktop.
Save kokosing/8f60122f74c355b1aaa0d1d2aa194e02 to your computer and use it in GitHub Desktop.
Parse thread dumps file
#!/bin/bash
set -exuo pipefail
# Usage <file with thread dumps> <output dir>
rm -rf $2
mkdir $2
cp $1 $2
cd $2
vim -c ':%s/\nFull thread/ Full thread/|:wq' $1
split -p 'Full thread' $1 dump_
for f in dump_*; do
mkdir ${f}_threads
split -p '".*"' $f ${f}_threads/thread_
pushd ${f}_threads
for state in CompilerThread http-client http-worker Query- TIMED_WAITING WAITING RUNNABLE BLOCKED; do
mkdir $state
for t in thread_*; do
if grep $state $t -q; then
mv $t $state
fi
done
done
touch thread_empty
cat thread_* > rest
rm thread_*
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment