 |
Mustang JConsole
Posted by mandychung on May 04, 2006 at 11:55 PM | Comments (15)
JavaOne 2006 Conference is coming up soon! Our BOF "Using JConsole to Monitor and Manage Your Application" is on May 18, 2006 at 10:30pm. The 9:30pm BOF (same room) is the JDK Tools BOF. The Java SE serviceability team will be there. It's late at night but hope to see you there. We're going to do a live demo of the Mustang JConsole at the JConsole BOF.
Below gives you a summary of the Mustang JConsole features. Let us know what you think.
JConsole Plugin Support
A new com.sun.tools.jconsole.JConsolePlugin API is added in Mustang. You can build your custom plugin to run with JConsole, for example, to add a new tab to access your application MBeans.
JTop is a JDK demo that shows the thread CPU usage of all threads running in the application. This demo is helpful to identify the threads that has high CPU consumption. It is updated to be used as a standalone GUI as well as a JConsole plugin. To run JConsole with the JTop plugin:
<JDK6>/bin/jconsole -pluginpath <JDK6>/demo/management/JTop/JTop.jar
To build a JConsole plugin, it's very simple:
1. Create a subclass of JConsolePlugin class and implement the getTab method and also the newSwingWorker method. The getTab method returns the list of tabs to be added to JConsole or an empty list. The newSwingWorker method returns the SwingWorker to be responsible for the plugin's GUI update.
2. Create a file "META-INF/services/com.sun.tools.jconsole.JConsolePlugin" to contain the fully-qualified class name of the plugin class. JConsole uses the service-provider loading facility to look up and load the plugins. You can have multiple plugins - one entry per plugin.
Sundar added a new scripting demo to demonstrate the power of using scripting language with JMX technology and the out-of-the-box manageability. This scripting demo is built as a JConsole plugin. It adds a scripting shell tab in JConsole where you can access MBean attributes or operations using a scripting language. To try, run JConsole as follows:
<JDK6>/bin/jconsole -pluginpath <JDK6>/demo/scripting/jconsole-plugin/jconsole-plugin.jar
Check out the file <JDK6>/demo/scripting/jconsole-plugin/src/resources/jconsole.js for the javascript commands. A few commands for you to start with:
> memory=mbean("java.lang:type=Memory") # to get the MemoryMXBean
> memory.Verbose # get the value of "Verbose" attribute
> memory.Verbose=true # set the "Verbose" attribute to true
> memory.gc() # invoke the gc() operation
Dynamic Attach Capability
JConsole can now attach to any applications running on Mustang JDK even if it wasn't started with -Dcom.sun.management.jmxremote option. This dynamic attach capability uses the attach API that Alan Bateman added in Mustang which enables a tool like JConsole to load the management agent in the target VM dynamically. It's a very useful feature and makes JConsole and the out-of-the-box management easier.
UI Improvements
There are many UI improvements in Mustang JConsole. Just to highlight a few: (1) JConsole now is using the system look-and-feel on Windows and Gnome desktop. (2) The connection dialog has been improved for user experience and a new sheet dialog is designed for the progress bar. (3) The thread tab now has a new detect deadlock button that finds the deadlocks involved in object monitors and java.util.concurrent ownable synchronizers. See the blog about "Thread dump and concurrent locks".
Overview Tab and VM Summary Tab
A new overview tab is added in Mustang JConsole to plot multiple charts in one tab to provide an easy way for users to correlate various resource consumption. Previously you would have to switch among several tabs if you want to correlate the data such as memory usage, threads, and CPU usage. Another improvement is that we merge the Summary tab and VM tab into one single "VM Summary" tab where you can cut-and-paste the selected text into a report file.
JMX MBean Metadata and Descriptor
JMX Descriptor provides a convenient way to add additional metadata to your MBeans. Mustang JMX supports descriptors for all types of MBeans. Eamonn's blog describes an easy way to add descriptors to your MBeans. Mustang JConsole makes the MBean metadata and descriptor information visible in the MBean tab.
HotSpot Diagnostic MBean
Mustang adds a HotSpot Diagnostic MBean (see com.sun.management.HotSpotDiagnosticMBean) which provides an API to request heap dump at runtime and also change the setting of certain VM options. You can access the HotSpot Diagnostic MBean via JConsole MBean tab. See Sundar's blog about setting VM options and my blog about diagnosing memory problems.
Try the latest version of Mustang JConsole and send us feedback!
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Hi Mandy, I'm planning to attend your BOF. I'm hoping you'll consider attending mine as well - I will focus on tools like YourKit and the NetBeans Profiler, but I'll have a slide about JConsole. :-)
Thursday night is a good night for folks who are interested in these types of tools - my BOF is at 8:30, and then at 9:30 there's the JDK tools BOF, and then of course you folks at 10:30.
Posted by: gsporar on May 05, 2006 at 02:14 PM
-
Do you know if the attach API can be used to call a method into the currently running JVM?
If no, Is there another way to do that?
if yes, do you know someone that has already implemented something like that?
Posted by: imjames on May 05, 2006 at 11:54 PM
-
The attach API provides a way to load a Java agent in the target application. This is designed to enable a tool such as management tool, profiler or debugger to load their tool agent lazily on demand.
You will find useful information about the attach API from several blogs from my colleagues including Alan's blog about " late-binding agent", Sundar's blog about " Mustang attach API", and also Chris's blog about " using the attach API to diagnose a problem".
Hope this helps.
Posted by: mandychung on May 08, 2006 at 05:25 PM
-
Just a small note for people blindly typing in the jconsole command: in the 1.6.0 beta the JTop.jar can be found in the demo/management/JTop folder (this is a folder deeper that the one stated in the article).
Furthermore, it does not seem to run without a host/port to monitor (which is somewhat logical, since JTop is a thread monitor, not so much a process monitor).
For a JConsole newbe like me, this is slightly too confusing, you're better off using the README.txt in the JTop demo.
Posted by: mbodewes on May 29, 2006 at 04:00 PM
-
Hello..Mandy..I got a problem to measure the cpu status while cpu usage may jump to 1000%,and all the graph is just a line...is there a way to fix the top cpu usage so that a cpu usage jump(maybe 1200%) will not force the graph to be just a line?
Posted by: inchlin on May 29, 2006 at 11:08 PM
-
It would greatly help if you report a bug at http://bugs.sun.com and describe how to reproduce the problem. Screenshots would really help too.
Posted by: mandychung on May 30, 2006 at 11:17 AM
-
I updated the blog with the correct path for the command to run JTop plugin. Thanks mbodewes for pointing out the typo!
Posted by: mandychung on May 30, 2006 at 11:19 AM
-
Hi, I just tried JConsole, and wanted to get a heap dump from the JVM being monitored, using the HotSpot Diagnostic MBean. However, when I click the MBean tab in Jconsole, the com.sun.management "folder" is not there. Any idea why that is? I am using Mustang build 1.6.0-rc-b87 for both JConsole and the app being monitored.
Posted by: johnemb on June 14, 2006 at 05:32 AM
-
I reported a bug last night about not being able to see any of my custom MBeans in the 1.6 jconsole (they're all there in the 1.5 jconsole). Maybe it's not a bug, but I don't see any options that I'm missing...
Posted by: mcgregorandrew on June 23, 2006 at 07:52 AM
-
hi mandy..can we have a function that we can search thread context instead only can search by it's name?
for example,i found one job cost a lot of cpu time,and i want search for class name through thread list..jtop is good that tell me which thread is in trouble,but can not let me search it by class name
Posted by: inchlin on July 20, 2006 at 06:49 PM
-
Thanks so much for posting this article. I've finally found the deadlock that was stopping my applicaiton.
Posted by: kitfox on July 28, 2006 at 03:22 PM
-
Hi Mandy. I keep getting the "Error calling isBroadcaster: " message in the JConsole output window. Can you give me a hint how to avoid this or why this is logged? I'm (basically) using Eamonn's AnnotatedStandardMBean as described in http://weblogs.java.net/blog/emcmanus/archive/2005/07/adding_informat.html
Searching the web for the error message did not really give me a clue.
Best, Stefan
Posted by: stefanjesse on February 13, 2007 at 11:05 PM
-
Hi Mandy, I hope you can help me i was looking for weeks how to solve this issue, and here is the only place i found something that could mathc my search keywords.
The problem is that i am getting this meesage in the jconsole output: Error calling isBroadcaster: com.sun.management:type=HotSpotDiagnostic is not registered..
I have no info about threads, but all the other metrics are being collected fine.
COuld you please give me some hints how to fix or workaround this issue???
Posted by: sebapereyro on June 14, 2007 at 11:09 AM
-
Hi Stefan and Seba,
The isBroadcaster error message is displayed when a given MBean is being added to the MBean tree and the check that verifies if the MBean to be registered can emit notifications fails because the MBean is no longer registered or there is a communication problem.
Seba says he has encountered problems with the threads tab too so there must be a problem at some point when initializing the JMX agent because it seems that access to some JVM MXBeans fails and some of them are missing. For example, the exception message tells that the HotSpotDiagnostic MXBean hasn“t been registered in the platform MBeanServer.
Which OS and Java Platform are you running on? Are you using the out-of-the-box management agent and platform MBeanServer?
We need all this info in order to try to reproduce the problem.
Please post any JConsole related problem to the SDN JMX forum.
Regards,
Luis
Posted by: lmalvent on June 15, 2007 at 02:23 AM
-
How to auto-reconnect once the connection is closed?
If jvm need to be restarted everyday,how to reconnect jconsole to it automatically?
Thanks for your response!
Posted by: inchlin on January 15, 2008 at 07:26 PM
|