Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remotely retrieve a java thread dump

Tags:

java

jmx

JVisualVM connects to a Java process over JMX and can produce a thread dump through the click of a button. I'd like to add a similar feature to my own application so that it can request thread dumps from remote services.

Which MBeans do I need to interrogate to get this information? and how?

like image 628
chillitom Avatar asked Jun 30 '11 12:06

chillitom


Video Answer


2 Answers

You can use MBean with name "java.lang:type=Threading". It's interface is described here.

In order to get thread dump you first need to use getAllThreadIds method and then loop through all retrieved ids and call getThreadInfo method for each of them.

like image 166
Andrey Adamovich Avatar answered Oct 17 '22 15:10

Andrey Adamovich


You can use the ThreadMXBean management interface.

This FullThreadDump class demonstrates the capability to get a full thread dump and also detect deadlock remotely using JMX.

like image 22
dogbane Avatar answered Oct 17 '22 15:10

dogbane