Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub

Java Flight Recorder Management Documentation

This documentation describes two scripts: one for starting and another for stopping Java Flight Recorder (JFR), as well as instructions on how to download, install, and run Java Mission Control.

Starting Java Flight Recorder: start_jfr.sh

What it does:

The first script is responsible for starting Java Flight Recorder (JFR) on a specific pod in a Kubernetes namespace. The script does the following:

  1. Defines the necessary environment variables like the Kubernetes namespace, recording name, settings, and pod prefix.
  2. Connects to the remote server using SSH with a specified user.
  3. Finds the pod by matching the provided prefix.
  4. Starts the JFR on the Java process inside the pod using jcmd, with a specified recording name, settings, and a duration of 999 hours.
  5. The JFR recording is saved to a specific file path inside the pod.

Variables:

  • VPS_HOST: The remote server's hostname or IP address.
  • SSH_USER: The username for SSH.
  • NAMESPACE: Kubernetes namespace where the pod resides.
  • RECORDING_NAME: The name of the JFR recording.
  • SETTINGS: The Java Flight Recorder settings.
  • POD_PREFIX: The prefix used to find the pod.

Stopping Java Flight Recorder: stop_jfr.sh

What it does:

The second script stops an active Java Flight Recorder (JFR) session on a specific pod in the Kubernetes namespace and downloads the recording file. The script performs the following actions:

  1. Defines environment variables like Kubernetes namespace, recording name, and pod prefix.
  2. Connects to the remote server using SSH with the provided user credentials.
  3. Finds the pod based on the prefix.
  4. Stops the JFR session using jcmd and the previously started recording name.
  5. Downloads the recording from the pod using kubectl cp and then transfers it from the remote server to the local machine using scp.

Variables:

  • VPS_HOST: The remote server's hostname or IP address.
  • SSH_USER: The username for SSH.
  • NAMESPACE: Kubernetes namespace where the pod resides.
  • RECORDING_NAME: The name of the JFR recording to stop.
  • POD_PREFIX: The prefix used to find the pod.
  • FILENAME: The file path where the JFR recording is stored inside the pod.

How to Install and Run Java Mission Control (JMC)

Here's how to install and run it on Linux:

Step 1: Download Java Mission Control

  1. Visit the Official JMC Download Page.
  2. Download the latest version of the Java Mission Control package for Linux.

Step 2: Install Java Mission Control

  1. Extract the downloaded .tar.gz archive:
    tar -xzf <path-to-jmc-tar.gz> -C /opt
    
  2. Optionally, create a symbolic link to make it easier to run:
    sudo ln -s /opt/jmc/jmc /usr/local/bin/jmc
    

Step 3: Launch Java Mission Control

You can now launch JMC from the terminal:

/opt/jmc/jmc

Or, if you created the symbolic link:

jmc

Step 4: Open JFR Recording

Once JMC is open, you can open JFR file that was downloaded using the second script.

Edit this page
Last Updated:
Contributors: gregory