Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating Windows Thread Dumps for Atlassian Review

red-blue-and-pink-thread-spool.jpg

As a Jira administrator, sometimes you need to get down to the OS level to figure out a performance issue. For many of us, OS-level work is not our strength; after all, we are Jira administrators and we are used to working in our Jira GUI. At most, we might read through the atlassian-jira.log file.

For a recent ticket that I opened with Atlassian, I was asked to create a series of thread dumps at different intervals. In this case, I was asked to provide 50 thread dumps every 3 seconds and 5 thread dumps every minute, for 55 thread dumps altogether. Being a developer, my first thought is “How can I automate this?”.

Here is my solution.

The first step is to make sure that you have jstack.exe installed. This comes with the Java JDK, not the JRE that ships with Jira. If you have not installed the JDK on the system where Jira is running, then download it from Oracle or OpenJDK. Note where it is installed. You will need this information to edit the script.

Next, you need to find the process that is running Jira. Open the Windows Task Manager and add the Process ID column to the view

image-20200430-150054.png

Look through the process list until you find your Jira process. Depending on whether you are running it as a service or from the command line, it will appear differently in your list. Regardless of how you find it, you will need the process id.

Now you are ready to get the thread dumps. The PowerShell Script that I wrote to automate this task is below

$processId = 6972
$jstack = "C:\Program Files\Java\jdk1.8.0_191\bin\jstack.exe"
$outdir = "C:\Users\RightStar\Documents\threaddump"

# get the thread dumps
# we need a filename, the number of runs to make
# The seconds and minutes indicate the time between runs
function get-thread ($fname, $runs, $seconds, $minutes) {

# Convert the seconds and minutes to seconds
$interval = $seconds + $minutes*60

for ($i=0;$i -lt $runs; $i++) {

# Get the current time for this run and set a filename
$start = (get-date)
$filename = "$fname$i.txt"
echo "Running iteration $i with interval of $interval seconds"

# Call jstack to create the thread dump
& $jstack -l $processId > "$outdir\$filename"

# Start a loop to wait until the time has elapsed
$datediff = (get-date)-$start
$elapsed = $datediff.seconds + $datediff.minutes*60
while ($elapsed -lt $interval) {
datediff = (get-date)-$start
$elapsed = $datediff.seconds + $datediff.minutes*60
}
}
}

# Get 50 threads with 3 second intervals
get-thread "3_seconddump" 50 3 0

# Get 5 threads with 1 minute intervals
get-thread "1_minutedump" 5 0 1

That is it. This script, which is commented internally, will run the thread dumps based on your parameters.

Feel free to use it, change it, improve on it. I hope it helps

1 comment

Mohammed Amine Community Leader Oct 01, 2020

Great article.

Comment

Log in or Sign up to comment
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,566 views 12 8
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you