Skip to content

Instantly share code, notes, and snippets.

@hammer
Created June 4, 2014 21:45
Show Gist options
  • Save hammer/3ce5da76571225528467 to your computer and use it in GitHub Desktop.
Save hammer/3ce5da76571225528467 to your computer and use it in GitHub Desktop.
#!/bin/bash
pid=$1
nsamples=$2
sleeptime=$3
for x in $(seq 1 $nsamples)
do
jstack $pid
sleep $sleeptime
done | \
awk 'BEGIN { s = "" }
/^"/ { if (s) print s; s = "" }
/^ at / { sub(/\([^)]*\)?$/, "", $2); sub(/^java/, "j", $2);
if (s) s = s "," $2; else s = $2 }
END { if(s) print s }' | \
sort | uniq -c | sort -rnk1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment