Project

General

Profile

How to get Java thread dump in Jboss » History » Revision 2

Revision 1 (chin-yeh, 11/11/2010 12:30 PM) → Revision 2/4 (chin-yeh, 11/11/2010 12:30 PM)

h1. How to get Java thread dump in Jboss 

 This guide is only applicable to: 
 * Linux OS with *netcat* package installed 
 * Jboss AS 4.x (it may work for Jboss 5.x) 

 *Steps* 
 # first, find out the Jboss's web listening port and address. 
 ## the listening port can be found in: 
 <pre> 
 ${Jboss Directory}/server/${profile name}/deploy/jboss-web.deployer/server.xml 
 </pre> 
 ## the listening address can be found in: 
 <pre> 
 netstat -tuna | grep ${listening port} 
 </pre> 
 # ssh to the target server 
 # *cd* to */tmp* 
 # execute the following command: 
 This command will output the result to current directory with a file named, thread_dump.${timestamp} 
 ** *Template:* 
 <pre> 
 $ 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) 
 </pre>  
 *** replace *listen_ip* with the listening IP 
 *** replace *listen_port* with the listening port 
 ** *Example:* 
 <pre> 
 $ 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) 
 </pre> 
 # append the *.html* to the output file 
 *From:* 
 <pre> 
 thread_dump.2010-11-11_12_08_26.html 
 </pre> 
 *To:* 
 <pre> 
 thread_dump.2010-11-11_12_08_26.html 
 </pre> 
 # download the output file to local machine 
 # done.