Skip to content

Instantly share code, notes, and snippets.

@mallipeddi
Last active October 7, 2015 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mallipeddi/3101985 to your computer and use it in GitHub Desktop.
Save mallipeddi/3101985 to your computer and use it in GitHub Desktop.
Poor Man's Profiler w/ pstack output on RHEL5
#!/bin/bash
nsamples=$2
sleeptime=$3
pid=$1
for x in $(seq 1 $nsamples)
do
pstack $pid && echo "--eos--"
sleep $sleeptime
done | \
awk '
BEGIN { s = ""; }
/--eos--/ { print s; s = ""; }
/Thread / { print s; s = ""; }
/#[0-9]*/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }' | sort | uniq -c | sort -r -n -k 1,1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment