Thursday, 7 February 2013

Setup remote server profiling with Jprofiler7 (Windows to Linux)

What is Profiling?

Analyze the performance of a Java program/JVM, by monitoring and collecting runtime data on object allocations, garbage collection cycles, CPU and memory usage, object references, method time stamps, threads and object interactions.


What is JProfiler?


Wiki says

"JProfiler is a commercially licensed Java profiling tool developed by ej-technologies GmbH, targeted at Java EE and Java SE applications."


At all times this is my first choice when it comes to profiling.


How to setup Remote profiling with Jprofiler  from Windows to Linux?

Summary 

  1. Download the Jprofiler EXE for windows and  tar.gz for linux
  2. Copy the tar file to linux and untar
  3. Remove linux firewall and selinux restrictions (if applicable)
  4. Run the JProfiler agent in linux
  5. Install JProfiler on windows and set the trial/commerical licence
  6. From JProfiler GUI, connect to the agent running on linux(Step 4)
  7. Start profiling

Lets walk through each step and see it working!


1. Download the Jprofiler EXE for windows and tar.gz for linux from here


2. Copy the tar file to linux and untar

  • Copy the file to a folder in linux

  • untar it using  "tar -xvf <tar filename>"
    This will untar the contents to a "jprofiler7" folder.


3. Remove linux firewall and selinux restrictions (if applicable)

Linux firewall and selinux might be turned on. Just disable those using the below commands. We can be enabled later after profiling
  • turnoff firewall :  service iptables stop
  • turnoff selinux :  setenforce 0


4. Run the JProfiler agent in linux

  • We should be linking the "server to be profiled" with the "untar'd jprofiler agent"
  • To do this we should add -agent VM parameter while running the server.
  • The same port specified here should be used when connecting from the GUI.
-agentpath:<installed folder> /jprofiler7/bin/linux-x64/libjprofilerti.so=port=<port number>

example :  -agentpath:/root/jprofiler7/bin/linux-x64/libjprofilerti.so=port=11002


Sample command to startup a jetty server

java -Djetty.home=/jetty -agentpath:/root/jprofiler7/bin/linux-x64/libjprofilerti.so=port=11002 -jar /jetty/start.jar

Now the server will startup with jprofiler agent, listening to Jprofiler GUI connections at port 11002.

5. Install JProfiler on windows and set the trial/commerical licence

Using the Executable we downloaded in step 1, install Jprofiler and set the appropriate licence and then start the Jprofiler

6. From JProfiler GUI, connect to the agent running on linux machine(Step 4)

  • Follow the steps as per the below diagram, the order are specified within the yellow circle.
  • Set the Linux Host IP or name and the same port specified with -agent in step 4. Example 11002.

You will pass through these screenshots as below:





7. Start Profiling

If you see the below screen, then it means you are connected.



References:



3 comments:

  1. Hi,

    Ihave set up Jprofiler in the exact same way. It's working but I can't restart the server if Jprofiler (from windows) is not open.

    We share the server between the team and it's big problem.

    Do you have any idea why it's is actling like that ?

    Thank you.

    Best regards,
    Damien.

    ReplyDelete
  2. Thanks Srividhya; Precise write-up; It helped me :)

    ReplyDelete