Search code examples
jprofiler

Problem profiling app using jpcontroller from linux commandline


I am attempting to use jpcontroller from the linux commandline, to profile a Java app (running on the same box) and save a snapshot for subsequent analysis on my local machine. However I see the following error on the stdout of the profiled app "JProfiler> Profiling session must be configured. Ignoring controller call."

This message is written whenever I select profiling options in the interactive jpcontroller session, (e.g start recording CPU data) and no profiling data file is written when selecting the jpcontroller option to save the data.

What might be preventing the profiler from being able to capture metrics and save a snapshot?

Details

- I am running jprofiler13.0.4

- The profiled app was launched using : OpenJDK Runtime Environment Temurin-17.0.8.1+1 (build 17.0.8.1+1)

- The INSTALL4J_JAVA_HOME env variable was also set to point at jdk-17.0.8.1+1-jre

- I have set the agentpath VM arg on the app being profiled

- I have tried both nowait and wait options before starting and attaching the jpcontroller to the app

The following is an example of the output from the app being profiled :

`Starting **BLAH** (monitor=, jmx-port=1, jmx-object-port=3 DEBUG=2)

Runtime location is : ** BLAH **

JProfiler> Protocol version 65

JProfiler> Java 17 detected.

JProfiler> 64-bit library

JProfiler> Listening on port: 8849.

JProfiler> Enabling native methods instrumentation.

JProfiler> Can retransform classes.

JProfiler> Can retransform any class.

JProfiler> Native library initialized

JProfiler> VM initialized

JProfiler> Retransforming 6 base class files.

JProfiler> Base classes instrumented.

JProfiler> Waiting for a connection from the JProfiler GUI ...

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

JProfiler> Profiling session must be configured. Ignoring controller call.

`

And the following shows a transcript of an attempt to use jpcontroller to capture and store metrics.

`./jpcontroller 28048

Connecting to ** BLAH **

Starting JMX management agent ...

GLib-GIO-Message: 13:18:55.972: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.

Connection established successfully.

Please select an operation:

Start recording [1]

Stop recording [2]

Enable triggers [3]

Disable triggers [4]

Heap dump [5]

Thread dump [6]

Add bookmark [7]

Save snapshot [8]

Quit [9]

1

Start recording of:

CPU data [1]

Allocations [2]

Thread data [3]

Monitor events [4]

VM telemetry data [5]

Complexity analysis [6]

Probes [7]

Please enter a comma-separated list of the selected values or [Enter] for the default selection:

[]

1,2,3

Operation successful.

Please select an operation:

Start recording [1]

Stop recording [2]

Enable triggers [3]

Disable triggers [4]

Heap dump [5]

Thread dump [6]

Add bookmark [7]

Save snapshot [8]

Quit [9]

8

Please enter the file name for the snapshot:

[snapshot_1.jps]

Saved snapshot to ** BLAH **/snapshot_1.jps`


Solution

  • The agent does not have any profiling settings, so it cannot record data.

    If you specify the "nowait" option, also specify the config= and the id= parameters to refer to a particular session configuration. The total parameter will look like

    -agentpath:/opt/jprofiler14/bin/linux-x64/libjprofilerti.so=port=8849,nowait,config=/path/to/config,id=123
    

    The session ID can be seen in the top-right corner on the application settings tab of the session settings.

    I would recommend configuring a session in JProfiler on your desktop machine in JProfiler and exporting it with Session->Export Session Settings. Then you can omit the "id" parameter because the config just contains a single session.

    If you do that, jpcontroller can start recording.