简体   繁体   中英

Tomcat thread dump

Is there away to take a thread dump from Tomcat. I want to monitor the running threads on Tomcat at a certain time.

Note: I was doing that on Web logic but i don't know how it cab be done on Tomcat.

如果你使用Linux,你可以发送一个kill -3 [你的tomcat的pid],它将转储catalina.out中的所有当前线程。

There is a simple way to monitor tomcat threads and do a dump. Start tomcat with the folowing java options :

-Dcom.sun.management.jmxremote.port=<some free port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

After the tomcat is restarted you can simply start jconsole (part of jdk) or visualvm and create a new jmx connection to the port you have chosen above.
In both tools you also have an option to take a dump ;)

!!!But do that only in closed/secured environment - since there is no authentication set.!!!

add java melody to your server https://code.google.com/p/javamelody/

it give you a lot of info including threads in runtime

The following steps should help you get the current Java threads running and analyze them:

  1. Download IBM JCA which is a nice thread dump analyzer from IBM Thread & Dump Monitor Analyzer
  2. Execute the following to get the Tomcat threads dump: root@localhost:~# sudo -u $TOMCAT_USER $JAVA_HOME/bin/jstack -J-d64 -l $(ps aux | grep '[c]atalina' | awk '{print $2}') > ~/threads.log
  3. Open the threads dump with IBM Thread & Dump Monitor Analyzer

Note: Replace $JAVA_HOME with your path to your current JDK, $TOMCAT_USER with the user running Tomcat; if you pass the wrong user or even using root you will get an error like this:

3047: well-known file is not secure

Please try netbeans profiler to profile any web applications.

https://profiler.netbeans.org/

http://wiki.netbeans.org/FaqProfilerAttachRemoteServer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM