Monday, November 17, 2014

Monitor cpu usage per thread in java...

There is a thread on SO , from which I discovered the TopThreads plugin for JConsole:

http://arnhem.luminis.eu/new_version_topthreads_jconsole_plugin/

jconsole -J-Djava.class.path=C:\Oracle\MIDDLE~1\JDK160~1\lib\jconsole.jar;C:\Oracle\MIDDLE~1\JDK160~1\lib\tools.jar;C:\Oracle\Middleware\wlserver_10.3\server\lib\wlfullclient.jar -J-Djmx.remote.protocol.provider.pkgs=weblogic.management.remote -pluginpath "c:\pierre\downloads\topthreads-1.1.jar" -debug

in the jconsole output you should see "Plugin class net.luminis.jmx.topthreads.PluginAdapter loaded."

and here you are: AWESOME!!!


Surely you can script it with ThreadJMX MBean, to create a monitoring tool, but this JConsole UI is so nice...

Also great is this trick: run TOP, then SHIFT-H, take the decimal value of the threads who eat more CPU, convert to HEX and match it to the nid in a jstack threadDump
http://code.nomad-labs.com/2010/11/18/identifying-which-java-thread-is-consuming-most-cpu/

No comments: