Remote profiling using SSH Port Forwarding (SSH Tunneling) on Linux

Table of contents
Reading Time: < 1 minute
In this blog post I’ll lay out few steps that are needed for remote profiling using SSH Port Forwarding (SSH Tunneling) using Yourkit profiler.
 
Steps to be followed on remote machine:
1) Download Yourkit profiler from official Yourkit website.
2) Extract the downloaded file anywhere.
3) What we need to do now is find the file named libyjpagent.so in the extracted folder corresponding to the system architecture of your remote machine. In my case it is located in yjp-2013-build-13086/bin/linux-x86-64.
4) Copy the libyjpagent.so file to any convenient location (if required), I copied it to /tmp/yjp folder.
5) Add the following VM option to the command line of your Java application:

-agentpath:/tmp/yjp/libyjpagent.so=port=7878

Here 7878 is the port that you will port forward to.
6) Your remote machine is all set for profiling.
 
Steps to be followed on local machine:
1) Port forward to remote machine by executing the following command on terminal:

ssh -N -f 1.2.3.4 -L 8085:1.2.3.4:7878

Explanation of what is going on in the above command:
-L 8085:1.2.3.4:7878 is forwarding port 7878 from 1.2.3.4 to localhost port 8085
-N -f parameters are forcing the ssh to go to background.
 
2) Download Yourkit profiler from official Yourkit website on you local machine as well.
3) Extract the downloaded file anywhere.
4) From terminal go to the following folder:
yjp-2013-build-13086/bin
and start Yourkit profiler using sh yjp.sh.
5) Now from yourkit profiler choose “Connect to remote application” option and enter localhost:8085 in the pop-up that asks for the link to your remote application.
6) Yourkit will start profiling your Java application on remote machine now.
 
 
 

Written by 

Sidharth is a Lead Consultant, having experience of more than 4.5 years. He has started working on Scala and Clojure and is actively involved in other developmental work. He enjoys working in a team and believes that knowledge is something that should be shared openly and on a large scale. As an avid gamer and passionate player, he likes to be involved in both indoor and outdoor activities.

2 thoughts on “Remote profiling using SSH Port Forwarding (SSH Tunneling) on Linux1 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading