Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Jprofile on linux system (No GUI)

Tags:

jprofiler

I have Linux system where jprofiler installed.

I have to profile one running server and one client together which lying on same Linux system. I am sending 100+ different request from client to server.

My query is:

  1. How to Automate whole jprofile process without GUI intervention?
  2. When start the jprofiling, before 100 request submitted to client or after?
  3. I haven't found config.xml (/root/.jprofiler8) after installing jprofiler in Linux system. How to create it?
  4. How to create session without GUI?

To analyse the jprofiler output I will copy on window system and will use GUI jprofiler.

Thanks in advance,

Edit-1

I can automate profiling procedure step 4 and 5 from below. All below steps are correct or not?

  1. Configure session using GUI as you suggested on yours reply (Session->Integration Wizards->New Remote Integration)

  2. export session using GUI as you suggested on yours reply (Session->Export Session Settings).

  3. Copy config.xml from window to Linux where jvm are running.

  4. Run jpenable in linux system like below: jpenable --pid=8568 --noinput --offline --config=/home/myuser/config.xml --id=106

  5. Run jpcontroller in Linux system like below and Save snapshot: jpcontroller 8568

  6. Copy snapshot output from Linux system to window and open snapshot(Session-> Open Snapshot) using jprofiler for further analysis.

Edit-2

-agentpath VM parameter added in start script instead of using my step 4. Now, can I start my created session to use JProfiler GUI instead of using my step 5-6? I am receiving connection error when select and start my session.

Session -> Start Center -> Select and Start session (e.g. id="138" name="Remote application on linux1")

Also, I ran "netstat -a | grep 8849" on Linux system but didn't get any result/output.

Replaced and executed step 4 like below:

linux1:/var/opt# su myuser

myuser@linux1:/var/opt> java -Xmx2g -agentpath:/opt/jprofiler8/bin/linux-x64/libjprofilerti.so=offline,id=138,config=/home/myuser/.jprofiler8/config.xml -classpath /opt/jprofiler8/bin/agent.jar -jar /opt/myapp.jar

JProfiler> Offline profiling mode.

JProfiler> Protocol version 41

JProfiler> Using JVMTI

JProfiler> JVMTI version 1.1 detected.

JProfiler> 64-bit library

JProfiler> Using config file /home/myuser/.jprofiler8/config.xml (id: 138)

JProfiler> Listening on port: 8849.

JProfiler> Instrumenting native methods.

JProfiler> Can retransform classes.

JProfiler> Can retransform any class.

JProfiler> Native library initialized

JProfiler> VM initialized

JProfiler> Using dynamic instrumentation

JProfiler> Time measurement: elapsed time

JProfiler> CPU profiling enabled

SLF4J: Class path contains multiple SLF4J bindings.

MyApp started

But, I am able use JProfiler GUI if i followed below steps instead of using my step 1-2-3-4-5-6 and it's not offline:

Step 1: Go to Linux jprofiler

myuser@linux1:/opt/jprofiler8/bin> ./jpenable

Select a JVM:

myapp.jar [29389] [1]

myapp2.jar [29228] [2]

1 Please select the profiling mode:

GUI mode (attach with JProfiler GUI) [1, Enter]

Offline mode (use config file to set profiling settings) [2]

1 Please enter a profiling port

[31757]

You can now use the JProfiler GUI to connect on port 31757

Step 2: Go to window jprofiler

Session -> New session -> [Attach (Squire shape Button) -> Attach to profiled JVM (radio button) --> Host: linux1 --> Profilling port: 31757 --> OK]

like image 661
Pawan Kumar Avatar asked Oct 19 '22 23:10

Pawan Kumar


1 Answers

You cannot create the triggers without a GUI. The idea is to configure the session locally on your desktop machine by invoking

Session->Integration Wizards->New Remote Integration

from the main menu. Select "Profile offline" in the "Startup mode step". The wizard will give you the VM parameter that you have to add on the remote side and create a new session on which you can configure triggers.

After that, export the session by invoking

Session->Export Session Settings

from the main menu and copy that config file to the remote server into the directory that you specified on the "Config synchronization" step of the wizard.

like image 74
Ingo Kegel Avatar answered Oct 23 '22 00:10

Ingo Kegel