Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

A thread dump gives insights into the state of a Java application at one point in time. It provides an overview of all active threads for the moment the snapshot is taken.

To be more useful for analysis and give a better representation of what is going on within an application it is common to create multiple of these snapshots at regular intervals. Ten dumps, one every 10 seconds could be an example of such a scheme.

Instructions

On a virtual machine

  1. Create a run script called jStackSeries.sh that looks as follows on your HiveMQ machine

    #!/bin/bash
    if [ $# -eq 0 ]; then
        echo >&2 "Usage: jstackSeries <pid> <run_user> [ <count> [ <delay> ] ]"
        echo >&2 "    Defaults: count = 10, delay = 0.5 (seconds)"
        exit 1
    fi
    pid=$1          # required
    user=$2         # required
    count=${3:-10}  # defaults to 10 times
    delay=${4:-0.5} # defaults to 0.5 seconds
    while [ $count -gt 0 ]
    do
        sudo -u $user jstack -l $pid >jstack.$pid.$(date +%H%M%S.%N)
        sleep $delay
        let count--
        echo -n "."
    done
  2. Find the HiveMQ run user <user> and process ID <pid> by running ps aux | grep hivemq

  3. Run the script as follows:
    sh jStackSeries-docker.sh <pid> <user> 20

  4. This will result in 20 files (filename: 'jstack.<pid>.<date>.N') being generated

  5. Please pack these 20 files in a zip file and attach them to your HiveMQ Support issue

 In docker

  1. Create the following run run-script jstack-series.sh

    #!/bin/bash
    if [ $# -eq 0 ]; then
        echo >&2 "Usage: jstackSeries [ <count> [ <delay> ] ]"
        echo >&2 "    Defaults: count = 10, delay = 0.5 (seconds)"
        exit 1
    fi
    count=${1:-20}  # defaults to 10 times
    delay=${2:-0.5} # defaults to 0.5 seconds
    while [ $count -gt 0 ]
    do
        ./jattach 1 threaddump>jstack.$pid.$(date +%H%M%S.%N)
        sleep $delay
        let count--
        echo -n "."
    done
  2. Run the following inside your Docker container:

    curl -L https://github.com/apangin/jattach/releases/download/v1.5/jattach > jattach && \
    chmod +x jattach
  3. Run the created script: ./jstack-series.sh

  4. This will result in 20 files (filename: 'jstack.<pid>.<date>.N') being generated

  5. Please pack these 20 files in a zip file and attach them to your HiveMQ Support issue

Make sure that you run the script with user that has the necessary permissions. (i.e. root or the HiveMQ run user)

  • No labels