Deprecated - jProfiler10 won't work in Java 11 JRE.
jProfiler debugging
Download jProfiler
Evaluate period or license key
jVisual VM might also help, but SSH tunneling not supported, needs JMX direct connection (verify)
Open needed ports
In the console go to EC2 instances, find the the wanted instance
In the description tab of the instance click on one of the security groups, e.g. Now-Internal-xyz-live or NOW_PUBLIC (opens all ports to public!)
Under inbound tab of the security group, Click edit
Add a custom TCP Rule for incoming SSH (22) and JMX (10002 , see /var/lib/tomcat/bin/setenv.sh)
- Or add existing security group.
- Make sure to roll back whatever was changed!
Connect jProfiler to JMX Port
- Direct connection did not work
- otherwise this is preferred
- check for running instances, see below.
- Used SSH Tunnel from jProfiler
- You can scan for running JVMs, just make sure you define the user owning the process (e.g. _mangolia_)
- NOTE: Per default it will shutdown the process, there's an option to keep it running. Set it!
Check for running JMX process
JMX port from /var/lib/tomcat/bin/setenv.sh
$ sudo lsof -i :10002 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 1584 dd-agent 29u IPv6 4442074 0t0 TCP ip-xyz.compute.internal:52296->xyz.compute.internal:10002 (ESTABLISHED) java 6876 magnolia 26u IPv6 50647 0t0 TCP *:10002 (LISTEN) java 6876 magnolia 102u IPv6 4443814 0t0 TCP ip-eu.compute.internal:10002->xyz.compute.internal:52296 (ESTABLISHED) ...@author1-live-...:/var/lib/tomcat8/bin$ ps aux | grep 6876 magnolia 6876 2.6 71.8 14288456 11470492 ? Sl May06 540:56 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat8/conf/logging.properties
UPDATED - Profiling remote JVM with JProfiler 11
Prerequisites
- Download & install JProfiler 11 to your local machine https://www.ej-technologies.com/download/jprofiler/version_111, license is in SRE keychain
SSH to remote machine, switch to user magnolia, download and extract JProfiler 11 tarball, start jpenable
ubuntu@public1-live-group1-site1:~$ sudo su - magnolia You are required to change your password immediately (password aged) su: Authentication token is no longer valid; new one required (Ignored) $ bash magnolia@public1-live-group1-site1:~$ wget https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_11_1_4.tar.gz --2021-01-11 08:52:02-- https://download-gcdn.ej-technologies.com/jprofiler/jprofiler_linux_11_1_4.tar.gz Resolving download-gcdn.ej-technologies.com (download-gcdn.ej-technologies.com)... 35.241.37.243 Connecting to download-gcdn.ej-technologies.com (download-gcdn.ej-technologies.com)|35.241.37.243|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 109022351 (104M) [application/x-tar] Saving to: ‘jprofiler_linux_11_1_4.tar.gz’ jprofiler_linux_11_1_4.tar.gz 100%[============================================================================================>] 103.97M 32.8MB/s in 3.2s 2021-01-11 08:52:07 (32.8 MB/s) - ‘jprofiler_linux_11_1_4.tar.gz’ saved [109022351/109022351] magnolia@public1-live-group1-site1:~$ tar xzvf jprofiler_linux_11_1_4.tar.gz ... magnolia@public1-live-group1-site1:~$ cd jprofiler11.1.4/bin/ magnolia@public1-live-group1-site1:~/jprofiler11.1.4/bin$ ./jpenable Connecting to org.apache.catalina.startup.Bootstrap start [13840] ... DANGER! The selected JVM uses class sharing. Under some circumstances, a bug in the JVM can cause the JVM to crash in attach mode. To avoid this problem, start the JVM with the VM parameter -Xshare:off Do you wish to proceed with attaching anyway? Proceed [p], Cancel [c, Enter] p Please select the profiling mode: GUI mode (attach with JProfiler GUI) [1, Enter] Offline mode (use config file to set profiling settings) [2] Please enter a profiling port [42795] You can now use the JProfiler GUI to connect on port 42795
Take note of above port.
Setup New Remote Integration
- From JProfiler 11 Menu, choose Session → Integration Wizards → New Remote Integration
- You need to allow access to the port in AWS security policies beforehand.
- On next dialogs, choose On a remote computer, Platform Linux x86/AMD64 → JVM Vendor: Oracle, Version 9+, Mode hotspot → Wait for a connection from JProfiler GUI → Direct connection to: public IP address of the remote instance → Remote installation directory: path to extracted JProfiler directory on remote instance, eg.: /home/magnolia/jprofiler11.1.4 → JProfiler port: enter the noted port from jpenable on remote instance → Finish