• Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • Data Center
    • None
    • 4
    • We collect Jira feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      Recommendation

      We should include scripts used to capture thread dumps in the product installer we ship. As an admin, having these scripts available at the ready during a performance incident will provide ease of mind and ease of capture, particularly should another staff member be monitoring the instance at any given time.

      When the product is unresponsive, the option to capture thread dumps inside of a support zip may not be available through the web interface.

      How to Capture Thread Dumps - Linux

      Manual commands

      Option 1 - jstack
      1. First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: ps aux | grep -i java
      2. Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
        for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
        

        NOTE: This will produce 12 text files in the directory from where this was run. If the 'jira_threads' files contain no data, then you will need to provide the fully qualified path to the jstack binary in the script. For example: If your jstack binary exists under /usr/java/bin/jstack , then the script would need to be modified as follows:

        for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; /usr/java/bin/jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
        
      1. Please, make sure to zip and attach all .txt files generated after running the commands (jira_cpu_usage and jira_threads) to the ticket.
      Option 2 - kill -3
      1. First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: ps aux | grep -i java
      2. Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
        for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; kill -3 $JIRA_PID; sleep 10; done
        
      1. The thread dumps will be placed in your catalina.out file
      2. Zip the catalina.out and jira_cpu_usage files that are generated and upload to your ticket

      Bash Script

      #!/bin/bash
      #
      # Thread dump script
      # Captures one thread dump every 10 seconds, 6 times
      # Thus, generating 6 thread dumps over the course of a minute
      # Replace "jira" in the APP_NAME declaration below for different products
      # This must be run as the same OS user the app runs as
      # Include the full path to jstack if it reports the command is not found
      # ex: JSTACK_PATH=/opt/java/jdk8u192-b12/bin/jstack
      
      APP_NAME=jira
      APP_PID=`ps aux | grep java | grep $APP_NAME | grep -v grep | awk '{print $2}'`
      JSTACK_PATH=jstack
      
      echo "Please wait 60 seconds for collection to complete"
      
      for i in $(seq 6)
              do
                      echo "Recording thread dump #" ${i}
                      top -b -H -p $APP_PID -n 1 > jira_cpu_usage.`date +%s`.txt
                      $JSTACK_PATH $APP_PID > jira_threads.`date +%s`.txt
                      sleep 10
                      done
      
      echo "Done"
      

      How to Capture Thread Dumps - Windows

      1. Download PsExec from Sysinternals
      2. Unzip the PSTools directory to a suitable place on your server.
      3. Open the unzipped PSTools folder, hold shift and right-click inside it, then select Open command window here (if you don't have the 'Open command window here' option you can run a command prompt as Administrator and navigate to the location of the PSTools folder using the command prompt)
      4. Identify the PID of the java (tomcat) process using Task Manager > Processes
      5. At the command prompt type psexec -s jstack XXXX > thread_dump_YY.log (where XXXX is your PID and YY is the number of the thread dumps taken to append to the name of the log file) then hit enter.
        1. If the jstack command is not recognized, you may need to enter the full path such as: psexec -s "C:\Program Files\Java\jdk1.8.0_201\bin\jstack.exe" XXXX > thread_dump_YY.log
      6. You'll need repeat the above 5 or 6 times, about 20 or 30 seconds between each execution, changing the YY each time, for example:
        psexec -s jstack 1234 > thread_dump_01.log
        -- wait ~10 seconds
        psexec -s jstack 1234 > thread_dump_02.log
        -- wait ~10 seconds
        psexec -s jstack 1234 > thread_dump_03.log
        -- wait ~10 seconds
        psexec -s jstack 1234 > thread_dump_04.log
        -- wait ~10 seconds
        psexec -s jstack 1234 > thread_dump_05.log
        -- wait ~10 seconds
        psexec -s jstack 1234 > thread_dump_06.log
        
      1. You should now have 6 files named thread_dump_YY.log in the PSTools folder.

      Note: If you still have issues with jstack, add the full path of your Java 'bin' directory to the server's system path variable. The Java 'bin' directory is usually in Program Files\Java\bin\jdk<version>\bin. If you add this path to the system variable then you will need to restart the command prompt again for the change to be picked up and the jstack command to work.

          Form Name

            [JSWSERVER-20155] Include script to capture thread dumps in the installer bundle

            SET Analytics Bot made changes -
            Support reference count New: 4
            TJ Royall made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 706755 ]

            For Atlassian-provided Docker templates, these are now bundled, see the "Troubleshooting" section of:

            https://bitbucket.org/atlassian-docker/docker-atlassian-jira/src/master/

            Rodrigo Baldasso added a comment - For Atlassian-provided Docker templates, these are now bundled, see the "Troubleshooting" section of: https://bitbucket.org/atlassian-docker/docker-atlassian-jira/src/master/
            Justin W. made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 630684 ]
            Justin W. made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 626497 ]
            Katherine Yabut made changes -
            Workflow Original: JAC Suggestion Workflow [ 3308752 ] New: JAC Suggestion Workflow 3 [ 3663233 ]
            Justin W. made changes -
            Description Original: h2. Recommendation

            We should include scripts used to capture thread dumps in the product installer we ship. As an admin, having these scripts available at the ready during a performance incident will provide ease of mind and ease of capture, particularly should another staff member be monitoring the instance at any given time.

            When the product is unresponsive, the option to capture thread dumps inside of a support zip may not be available through the web interface.
            h2. How to Capture Thread Dumps - Linux
             * [Generating A Thread Dump|https://confluence.atlassian.com/doc/generating-a-thread-dump-188095.html]

            h4. Manual commands
            h6. Option 1 - jstack
            {panel}
             # First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: {{ps aux | grep -i java}}
             # Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
            {code}
            (i) *NOTE*: This will produce 12 text files in the directory from where this was run. If the 'jira_threads' files contain no data, then you will need to provide the *fully qualified path* to the *jstack* binary in the script. For example: If your *jstack* binary exists under /usr/java/bin/jstack , then the script would need to be modified as follows:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; /usr/java/bin/jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
            {code}

             # Please, make sure to zip and attach all .txt files generated after running the commands (jira_cpu_usage and jira_threads) to the ticket.{panel}
            h6. Option 2 - kill -3
            {panel}
             # First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: {{ps aux | grep -i java}}
             # Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; kill -3 $JIRA_PID; sleep 10; done
            {code}

             # The thread dumps will be placed in your catalina.out file
             # Zip the catalina.out and jira_cpu_usage files that are generated and upload to your ticket{panel}
            h4. Bash Script
            {code:java}
            #!/bin/bash
            #
            # Thread dump script
            # Captures one thread dump every 10 seconds, 6 times
            # Thus, generating 6 thread dumps over the course of a minute
            # Replace "jira" in the APP_NAME declaration below for different products
            # This must be run as the same OS user the app runs as
            # Include the full path to jstack if it reports the command is not found

            APP_NAME=jira
            APP_PID=`ps aux | grep java | grep $APP_NAME | grep -v grep | awk '{print $2}'`
            JSTACK_PATH=jstack

            echo "Please wait 60 seconds for collection to complete"

            for i in $(seq 6)
                    do
                            echo "Recording thread dump #" ${i}
                            top -b -H -p $APP_PID -n 1 > jira_cpu_usage.`date +%s`.txt
                            $JSTACK_PATH $APP_PID > jira_threads.`date +%s`.txt
                            sleep 10
                            done

            echo "Done"
            {code}
            h2. How to Capture Thread Dumps - Windows
             # [Download PsExec|https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx] from Sysinternals
             # Unzip the *PSTools* directory to a suitable place on your server.
             # Open the unzipped *PSTools* folder, hold shift and right-click inside it, then select *Open command window here* (if you don't have the 'Open command window here' option you can run a command prompt as Administrator and navigate to the location of the PSTools folder using the command prompt)
             # Identify the PID of the java (tomcat) process using Task Manager > Processes
             # At the command prompt type {{psexec -s jstack XXXX > thread_dump_YY.log}} (where XXXX is your PID and YY is the number of the thread dumps taken to append to the name of the log file) then hit enter.
             ## If the jstack command is not recognized, you may need to enter the full path such as: {{psexec -s "C:\Program Files\Java\jdk1.8.0_201\bin\jstack.exe" XXXX > thread_dump_YY.log}}
             # You'll need repeat the above 5 or 6 times, about 20 or 30 seconds between each execution, changing the YY each time, for example:
            {code:java}
            psexec -s jstack 1234 > thread_dump_01.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_02.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_03.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_04.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_05.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_06.log
            {code}

             # You should now have 6 files named thread_dump_YY.log in the PSTools folder.

            (i) *Note:* If you still have issues with jstack, add the full path of your Java 'bin' directory to the server's system path variable. The Java 'bin' directory is usually in {{Program Files\Java\bin\jdk<version>\bin}}. If you add this path to the system variable then you will need to restart the command prompt again for the change to be picked up and the {{jstack}} command to work.
            New: h2. Recommendation

            We should include scripts used to capture thread dumps in the product installer we ship. As an admin, having these scripts available at the ready during a performance incident will provide ease of mind and ease of capture, particularly should another staff member be monitoring the instance at any given time.

            When the product is unresponsive, the option to capture thread dumps inside of a support zip may not be available through the web interface.
            h2. How to Capture Thread Dumps - Linux
             * [Generating A Thread Dump|https://confluence.atlassian.com/doc/generating-a-thread-dump-188095.html]

            h4. Manual commands
            h6. Option 1 - jstack
            {panel}
             # First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: {{ps aux | grep -i java}}
             # Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
            {code}
            (i) *NOTE*: This will produce 12 text files in the directory from where this was run. If the 'jira_threads' files contain no data, then you will need to provide the *fully qualified path* to the *jstack* binary in the script. For example: If your *jstack* binary exists under /usr/java/bin/jstack , then the script would need to be modified as follows:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; /usr/java/bin/jstack $JIRA_PID > jira_threads.`date +%s`.txt; sleep 10; done
            {code}

             # Please, make sure to zip and attach all .txt files generated after running the commands (jira_cpu_usage and jira_threads) to the ticket.{panel}
            h6. Option 2 - kill -3
            {panel}
             # First, identify the Process ID for Jira (referred here as the $JIRA_PID) using the command: {{ps aux | grep -i java}}
             # Using the $JIRA_PID while logged in as the user that runs Jira, run the following script in the terminal:
            {code:java}
            for i in $(seq 6); do top -b -H -p $JIRA_PID -n 1 > jira_cpu_usage.`date +%s`.txt; kill -3 $JIRA_PID; sleep 10; done
            {code}

             # The thread dumps will be placed in your catalina.out file
             # Zip the catalina.out and jira_cpu_usage files that are generated and upload to your ticket{panel}
            h4. Bash Script
            {code:java}
            #!/bin/bash
            #
            # Thread dump script
            # Captures one thread dump every 10 seconds, 6 times
            # Thus, generating 6 thread dumps over the course of a minute
            # Replace "jira" in the APP_NAME declaration below for different products
            # This must be run as the same OS user the app runs as
            # Include the full path to jstack if it reports the command is not found
            # ex: JSTACK_PATH=/opt/java/jdk8u192-b12/bin/jstack

            APP_NAME=jira
            APP_PID=`ps aux | grep java | grep $APP_NAME | grep -v grep | awk '{print $2}'`
            JSTACK_PATH=jstack

            echo "Please wait 60 seconds for collection to complete"

            for i in $(seq 6)
                    do
                            echo "Recording thread dump #" ${i}
                            top -b -H -p $APP_PID -n 1 > jira_cpu_usage.`date +%s`.txt
                            $JSTACK_PATH $APP_PID > jira_threads.`date +%s`.txt
                            sleep 10
                            done

            echo "Done"
            {code}
            h2. How to Capture Thread Dumps - Windows
             # [Download PsExec|https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx] from Sysinternals
             # Unzip the *PSTools* directory to a suitable place on your server.
             # Open the unzipped *PSTools* folder, hold shift and right-click inside it, then select *Open command window here* (if you don't have the 'Open command window here' option you can run a command prompt as Administrator and navigate to the location of the PSTools folder using the command prompt)
             # Identify the PID of the java (tomcat) process using Task Manager > Processes
             # At the command prompt type {{psexec -s jstack XXXX > thread_dump_YY.log}} (where XXXX is your PID and YY is the number of the thread dumps taken to append to the name of the log file) then hit enter.
             ## If the jstack command is not recognized, you may need to enter the full path such as: {{psexec -s "C:\Program Files\Java\jdk1.8.0_201\bin\jstack.exe" XXXX > thread_dump_YY.log}}
             # You'll need repeat the above 5 or 6 times, about 20 or 30 seconds between each execution, changing the YY each time, for example:
            {code:java}
            psexec -s jstack 1234 > thread_dump_01.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_02.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_03.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_04.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_05.log
            -- wait ~10 seconds
            psexec -s jstack 1234 > thread_dump_06.log
            {code}

             # You should now have 6 files named thread_dump_YY.log in the PSTools folder.

            (i) *Note:* If you still have issues with jstack, add the full path of your Java 'bin' directory to the server's system path variable. The Java 'bin' directory is usually in {{Program Files\Java\bin\jdk<version>\bin}}. If you add this path to the system variable then you will need to restart the command prompt again for the change to be picked up and the {{jstack}} command to work.
            Justin W. created issue -

              Unassigned Unassigned
              jwyllys Justin W.
              Votes:
              5 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: