How to setup and capture Java JVisualVM logging for collecting Thread Dumps or HEAP dumps when the CPU on the Mid Tier is showing the Tomcat process using up too much CPU. |
This knowledge article may contain information that does not apply to version 21.05 or later which runs in a container environment. Please refer to Article Number 000385088 for more information about troubleshooting BMC products in containers. Here are the steps to setup the capture using jVisualVM on your Mid Tier server: JVM monitoring setup (to use jvisualvm) 1. Start the JVM with the following additional args (make sure that port 8088 is free on your machine or use another port):
If there are any issues with the connection failing to establish for Java 7 and above, the RMI port parameter needs to be added . -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=<PORT-Number>
-Dcom.sun.management.jmxremote.rmi.port=<PORT-Number>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=<JVM-Server-IP-Address>
Similarly for a Linux environment below : JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"; export JAVA_OPTS
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=<PORT-Number>"; export JAVA_OPTS JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.rmi.port=<PORT-Number>"; export JAVA_OPTS JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"; export JAVA_OPTS JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"; export JAVA_OPTS JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname=<JVM-Server-IP-Address>"; export JAVA_OPTS For, -Dcom.sun.management.jmxremote.port=<PORT-Number> and -Dcom.sun.management.jmxremote.rmi.port=<PORT-Number> the port can be the same or different , If there are security/Firewalll constraints, you can keep both the jmx port and RMI port as same . 2. Launch <jdk>/bin/jvisualvm.exe 3. Select “File | Add Remote Host…” (skip this step and the next step if jvisualvm was launched on the same machine as the JVM) 4. Type in the hostname or the IP address in the dialog box 5. For remote monitoring, use step a. For local monitoring, use step b. a. Remote monitoring: The host will show in the navigation tree; select, right-click, choose “Add JMX Connection…” b. Local monitoring: Select “File | Add JMX Connection…” 6. For remote monitoring, type in our JMX port number 8088; for local monitoring, type in “localhost:8088” 7. The JMX connection will show up in the navigation tree; select and double-click to start monitoring 8. To change interval to 24 hours from the default: Choose “Tools | Options” and enter 1,440 for Charts Cache 9. After sufficient data is collected, select the node in the navigation tree, right-click, and choose “Application Snapshot” 10. The snapshot will show up with timestamp in the navigation tree under the tree “Snapshots” 11. Select the snapshot, right-click, and choose “Save As…” to save the JVM monitoring data a) Launch the jvisualvm console and connect to the Tomcat jvm hosting the midtier.
b) Click on the Threads tab c) Click on the Thread Dump button. The Thread dump will be displayed on the console. d) Rightclick on the threaddump in the lefthand tree and select Save As... To gather a heap dump: a) Launch the jvisualvm console and connect to the Tomcat jvm hosting the midtier.
b) Click on the Montitor tab c) Click on the Heap Dump button. The Heap dump will be displayed on the console. d) Rghtclick on the heap dump in the lefthand tree and select Save As... Note: You may also want to consider Garbage collection logging in order to obtain a better performance picture: How to collect Garbage Collection (GC) log of Tomcat on Windows / Linux environment. |