Can JConsole data be retrieved.
I have my servers running for 3 days and I had enabled JConsole setting before I started my servers.
Question 1
If I open the JConsole Window now, can JConsole give me the memory usage graph of the past 3 days. Or, does it show only the memory usage form current time onwards.
I have noticed that JConsole shows the memory graph from current time onwards till the JConsole window is open(provided the servers are running).
I am not interested in keeping the Jconsole window open forever, but rather open it at convenient time. hence the above question
Question 2
Is it possible to retrieve the memory data from the MBeanServer that is used to plot the memory graph on JConsole.
Any answers would be of great help. I am currently using J5.0
thanks
Ants
Answer 1: It shows only the memory usage form current time onwards.
Answer 2: The platform MBeanServer exposes the following MXBeans
that allow to get all the memory usage information:
ClassName: java.lang.management.MemoryMXBean
ObjectName: java.lang:type=Memory
ClassName: java.lang.management.MemoryPoolMXBean
ObjectName: java.lang:type=MemoryPool,name=pool's name
Have a look at the Monitoring and Management Guide for more detailed info:
http://java.sun.com/javase/6/docs/technotes/guides/management/index.html
Regards,
Luis-Miguel Alventosa
Java SE JMX/JConsole development team
Sun Microsystems, Inc.
http://blogs.sun.com/lmalventosa
In response to Answer 1
--
It means that the memory usage data points are collected only when the JConsole GUI is up. Else the MBeanServer is Running but it never collects the memory data and hold it.
So, if the JConsole GUI is up, would this memory data be held in the cache.? Because there are options to do a time based graph( I mean the Y-axis Tiime range can be changed) and for this the MBeanServer may have to get the memory usage data points from its cache.
if the Data is held in the cache and I have the JConsole up for 3 months, wouldn't the MBean Server have a hude data in it to hold. Will that impact the performance of the JVM?
thanks for your help and insight and knowledge sharing.
-Ants
Currently the memory usage data points are collected by JConsole but are not persisted, they are kept in memory forever. Unfortunately this means you won磘 be able to run JConsole for three months because you will likely run out of memory before that.
In future versions of JConsole we plan to persist plotter data points to disk to avoid the memory overflow problem.
-Luis
Thanks Luis.
It would be great to add the feature that you just spoke about.
Getting at least a CSV dump of the memory and other possible parameters would be would be good enough.
I plan to use the notification feature till then. I am hitting OOMError quit frequently and starting JConsole after I get the heap usage touching 90% notification is not of much help since I may have missed on some importnat Memory usage history data points.
I appreciate you quick response.
thanks
Ants
You can already get a CSV dump of the different memory pools. In fact, you can get a CSV dump of any plotter in JConsole by right-clicking on the plotter and selecting Save data as... in the popup menu. Before you get to 90% heap usage you could persist the data.
Have a look in SDN at JavaOne 2007 Hands-On Lab 1420 on Troubleshooting with JConsole for more detailed info about not very well-known but very useful JConsole features.
http://developers.sun.com/learning/javaoneonline/sessions/hol2007/1420/jmxjconsole/index.html
-Luis
You could also write your own monitoring program if you want to sample and save
the data to a file.
See here on how to access the JVM information programmatically:
http://blogs.sun.com/jmxetc/entry/how_to_retrieve_remote_jvm
Hope this helps,
-- daniel
JMX, SNMP, Java, etc...
http://blogs.sun.com/jmxetc