Project

General

Profile

How to get Java thread dump in Jboss » History » Version 4

chin-yeh, 11/11/2010 12:36 PM

1 2 chin-yeh
h1. How to get Java thread dump in Jboss
2 1 chin-yeh
3
This guide is only applicable to:
4
* Linux OS with *netcat* package installed
5
* Jboss AS 4.x (it may work for Jboss 5.x)
6
7
*Steps*
8
# first, find out the Jboss's web listening port and address.
9
## the listening port can be found in:
10
<pre>
11
${Jboss Directory}/server/${profile name}/deploy/jboss-web.deployer/server.xml
12
</pre>
13 4 chin-yeh
## the listening address can be found through *netstat*:
14 1 chin-yeh
<pre>
15 4 chin-yeh
$ netstat -tuna | grep ${listening port}
16 1 chin-yeh
</pre>
17
# ssh to the target server
18
# *cd* to */tmp*
19
# execute the following command:
20
This command will output the result to current directory with a file named, thread_dump.${timestamp}
21
** *Template:*
22
<pre>
23
$ echo -e "GET /jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system%3Atype%3DServerInfo&methodIndex=1 \n\n"  | nc listen_ip listen_port | cat > thread_dump.$(date +%Y-%m-%d_%H_%M_%S)
24
</pre> 
25
*** replace *listen_ip* with the listening IP
26
*** replace *listen_port* with the listening port
27
** *Example:*
28
<pre>
29
$ echo -e "GET /jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system%3Atype%3DServerInfo&methodIndex=1 \n\n"  | nc 127.0.0.1 8080 | cat > thread_dump.$(date +%Y-%m-%d_%H_%M_%S)
30
</pre>
31 4 chin-yeh
# append the *.html* to the output's filename
32 1 chin-yeh
*From:*
33
<pre>
34 3 chin-yeh
thread_dump.2010-11-11_12_08_26
35 1 chin-yeh
</pre>
36
*To:*
37
<pre>
38
thread_dump.2010-11-11_12_08_26.html
39
</pre>
40
# download the output file to local machine
41
# done.