Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Java thread dump in EC2 Amazon : No jstack found

We are experience 100% CPU usage issue after the server runs for 20-30mins. We are trying to troubleshoot.

I have read that we can use jstack to generate dump of high cpu thread.

However in Amazon ami jstack is not installed.

OpenJDK Runtime Environment (amzn-2.5.1.2.45.amzn1-x86_64 u65-b17)

Is there a way I can install jstack without reinstalling oracle build? Also is there any other solution to get dump?

like image 406
Siddharth Menon Avatar asked Oct 17 '14 08:10

Siddharth Menon


People also ask

How can we get Java thread dump of a program?

To take a thread dump, navigate to the console used to launch the Java application, and press the CTRL and Break keys together. It's worth noting that, on some keyboards, the Break key isn't available. Therefore, in such cases, a thread dump can be captured using the CTRL, SHIFT, and Pause keys together.

What is Jstack in Java?

Description. The jstack command prints Java stack traces of Java threads for a specified Java process. For each Java frame, the full class name, method name, byte code index (BCI), and line number, when available, are printed.


1 Answers

Try following command:

kill -quit <java process id>

The threads stackthreadses should be appended to default output. More information available here

like image 122
Eugene Chipachenko Avatar answered Oct 27 '22 16:10

Eugene Chipachenko