Is there any way to see more information on who initiated a Java thread?

I recently had a single Java thread out of my confluence instance run away from me. Using top -H, I could see that this thread was consistently running CPU usage up to 99.9% while all the others appeared normal.

Is there any way I can map this thread to a single user or to a single IP address or to a single task. Perhaps next time this happens I can ask the user to stop what they are doing and log out rather than restart the entire Confluence service for everyone.

1 answer

1 accepted

This widget could not be displayed.

For the googlers,

I found this script elsewhere and it did the trick:

#!/bin/bash
PID=$(top -n1 | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' ')
echo The PID of the Confluence process is $PID
TID=$(top -n1 -H | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' ')
echo The PPID of the highest CPU consuming Java thread is $TID
NID=$(printf "%x" $TID)
echo The hex value of the highest CPU consuming Java thread is $NID
if [[ $PID -gt 0 && "$NID" != "0" ]]; then
        sudo /usr/java/jdk1.6.0_20/bin/jstack $PID | grep -A500 $NID | grep -m1 "^$" -B 500
fi;

echo -n "OS thread count is: "
ps -eL | grep java | wc -l

echo -n "Open file count is: "
sudo /usr/sbin/lsof | grep java | wc -l

echo -n "Total established connection count is "
sudo /usr/sbin/lsof -i | grep java | grep -i established | wc -l

echo -n "HTTPS incoming connection count is: "
sudo /usr/sbin/lsof -i | grep java | grep -i established | grep :https | wc -l

echo -n "Total other (outgoing) connection count is: "
sudo /usr/sbin/lsof -i | grep java | grep -i established | grep -v ":https" | wc -l

echo -n "Database (outgoing) connection count is: "
sudo /usr/sbin/lsof -i | grep java | grep -i established | grep "dbServer" | wc -l

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

466 views 6 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you