Skip to content

Instantly share code, notes, and snippets.

@fabrizioc1
Created November 9, 2011 01:16
Show Gist options
  • Save fabrizioc1/1349992 to your computer and use it in GitHub Desktop.
Save fabrizioc1/1349992 to your computer and use it in GitHub Desktop.
Script to trigger java dump when WebSphere JVM does a full GC
#!/bin/bash
#
# Run this in the background and keep it running when you log out run it like this:
# nohup /tmp/trigger_javadump.sh >/tmp/trigger_javadump.log 2>&1 &
#
FULLGC_PATTERN='^Application time: 0.0000'
VERBOSEGC_PATH='verbosegc.log'
while true; do
FULLGC_FOUND=$(grep "$FULLGC_PATTERN" "$VERBOSEGC_PATH")
if [ "$FULLGC_FOUND" ]; then
echo "Full GC found"
# Generate thread dump on all WebSphere instances running
for pid in $(pgrep -f WebSphere); do
kill -3 $pid
done
exit 0
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment