Skip to content

Instantly share code, notes, and snippets.

@code6
Created August 22, 2013 13:48
Show Gist options
  • Save code6/6307385 to your computer and use it in GitHub Desktop.
Save code6/6307385 to your computer and use it in GitHub Desktop.
dump hive process jstack
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: dump_sw_java.sh <keyword>"
fi
DUMPDIR=dump_dir
keyword=$1
ts=$(date +%H%M%S.%N)
for pid in `ps aux | grep python | grep $keyword | awk '{ print $2}'`; do
echo $pid
pstree -p $pid > $DUMPDIR/pstree.$keyword.$pid.$ts
javapid=$(pstree -p $pid | grep 'java(' | egrep -o 'java\([[:digit:]]+' | cut -d'(' -f 2)
if [[ $javapid =~ "^[0-9]+$" ]]; then
/usr/local/java/bin/jstack -l $javapid > $DUMPDIR/jstack.$keyword.$pid.$javapid.$ts
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment