Skip to content

Instantly share code, notes, and snippets.

@phact
Created April 30, 2015 22:38
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 phact/22aa5085e58a43de7425 to your computer and use it in GitHub Desktop.
Save phact/22aa5085e58a43de7425 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ $# -ne 3 ]; then
echo "Usage: $0 pid interval count"
exit 1
fi
PID=$1
INTERVAL=$2
COUNT=$3
top -bH -d $INTERVAL -n $COUNT -p $PID >> top.out 2>&1 &
for i in `seq $COUNT`; do
echo "stack trace $i of $COUNT" >> jstack.out
jstack -l $PID >> jstack.out
echo "--------------------" >> jstack.out
sleep $INTERVAL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment