How to take a thread/heap dump on newer(JDK11) based delegates

Howdy-

Since we updated our delegates to JDK11 the method has changed to retrieve heap/thread dumps from them as well. However, to save time here is a self-help article(which we will attempt to keep up-to-date with any changes) to grab either, or both:

Login to your delegate, and as the delegate user that the delegate JVM process is running as, which can be determined with something similar to:

ps aux |grep delegate.jar |grep -v grep |awk '{ print $1; }'

Now all we need to do is simply copy/paste this to a file and run it via bash, or copy/paste it as is in the terminal window if you prefer. If you JUST want the thread dump comment out line 6, if you just want the heap dump, comment out line 5. Once you have collected all the required dumps on the delegate, simply run the last line that is commented out (without the # of course!).

curl -L https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14%2B9/OpenJDK11U-jdk_x64_linux_hotspot_11.0.14_9.tar.gz -o /tmp/jdk11.tgz
tar -zxvf /tmp/jdk11.tgz -C /tmp
delegate_pid=`ps ax |grep delegate.jar |grep -v grep | awk '{ print $1 }'`
/tmp/jdk-11.0.14+9/bin/jcmd $delegate_pid Thread.print > /tmp/`date +%m%d-%H%M%S`-thread.dump
/tmp/jdk-11.0.14+9/bin/jcmd $delegate_pid GC.heap_dump /tmp/`date +%m%d-%H%M%S`-heapdump.bin

# Cleanup the downloads in /tmp when done, just run the commented line below:

# rm -rf {/tmp/jdk11.tgz,/tmp/jdk-11*}
3 Likes