To troubleshoot various performance issues, sometimes investigating multiple Java thread dumps is necessary. The method for generating these dumps can vary depending on the environment, but the commands in this article may work for many environments if the Nexus version is 3.79 and higher or jcmd is available.
As the correct OS user, for example nexus:
jcmdPath="" # Change this if 'jcmd' is not in the PATH
pid="$(${jcmdPath:-"jcmd"} | awk '/(nexus|org.springframework.boot.loader.launch.PropertiesLauncher)/ {print $1; exit}')";
logDir="$(dirname "$(ls -l /proc/${pid}/fd | grep -E -o '\S+/nexus.log$' | head -n1)")";
filePfx="${logDir}/tasks/script-$(date +"%Y%m%d%H%M%S")";
for i in {1..5};do (top -H -b -n1 | head -n60;netstat -topen 2>/dev/null || cat /proc/net/tcp* 2>/dev/null) >> ${filePfx}999.log; ${jcmdPath:-"jcmd"} ${pid} Thread.print -l; sleep 2; done > ${filePfx}000.log
# To verify
ls -l ${filePfx}*.logNOTE: the jcmd should be located under $JAVA_HOME/bin/. Or if the Nexus is using the bundled java:
$ cd ${Nexus_Installed_Dir}
$ find . -name jcmd
./nexus-3.79.0-09/jdk/temurin_17.0.13_11_mac_aarch64/jdk-17.0.13+11/Contents/Home/bin/jcmdIf the above commands don’t cause any errors and non-empty script-YYYYMMDDHHMMSSnnn.log files are generated, please generate the support zip without any size limit options.
If no jcmd available
NOTE: this method requires -XX:+LogVMOutput is set and -XX:LogFile points to the writable jvm.log.
As the correct OS user, for example nexus:
workingDirectory="/nexus-data" # Change this
filePfx="${workingDirectory%/}/log/tasks/script-$(date +"%Y%m%d%H%M%S")";
pid="$(head -n2 ${workingDirectory%/}/log/jvm.log | sed -n -E "s/.+ process='([^']+)'.+/\1/p")";
[ -n "${pid}" ] && (for i in {1..5};do top -H -b -n1 | head -n60;kill -3 ${pid};netstat -topen 2>/dev/null || cat /proc/net/tcp* 2>/dev/null;sleep 2;done;sed -n -E "/^[[:space:]]*$(date +"%Y-%m-%d %H")/,\$p" ${workingDirectory%/}/log/jvm.log) >> ${filePfx}909.log