Embed JConsole within our own application
Has anyone out there embedded a JConsole within their own application? Why might I want to do this? Well, we have a large number of Java applications running and we want to monitor them! Rather than have to run a hundred separate JConsoles, it would be nice to run one tool where we could navigation to the application (usinga JTree/JTable or whatever) and press alaunch JConsole button.
I've managed quite easily tofork the jconsole (from inside our all-systems-monitor) using:
String hostname ="locahost";//REALLY DISCOVER THIS PROPERLY
int port = 9999;//AND THIS!
String appRoot ="oxbow/jmx/my_app";//THIS TOO
final String url = String.format("service:jmx:rmi:///jndi/rmi://%s:%d/%s", hostname, port, appRoot);
final String execLocation = System.getenv("JAVA_HOME") +"/bin/jconsole";
new Thread(new Runnable(){
publicvoid run(){
try{
Process p = Runtime.getRuntime().exec(execLocation +" " + url);
p.waitFor();
}
catch (Exception e){
//HANDLE
}
}
}).start();
Which is cool, but it would be nice to be able to embed in the app itself.Are there any plans for Sun to create anAPI for this?
Hi,
Unfortunately, there isn磘 a supported JConsole API to do this currently. Maybe a nice RFE for JConsole in JDK 7.
At the moment the only thing you can do is to discover all the connector servers running and then start JConsole with all the URLs.
FYI, JConsole already supports multiple connections to multiple agents in a single process.
Regards,
Luis-Miguel Alventosa
JMX Java SE development team
Sun Microsystems, Inc.
> FYI, JConsole already supports multiple connections
> to multiple agents in a single process.
>
> Regards,
> Luis-Miguel Alventosa
> JMX Java SE development team
> Sun Microsystems, Inc.
We have hundreds of systems which our tool is set up to monitor (they heartbeat over our network using a messaging infrastructure and advertise their JMX service URL and we can view the "universe" as a heatmap). From a usage point of view, we only want to "drill-down" into an application's state if it is reporting that there's something wrong or we want invoke an MBean operation.
This is not the normal state of affairs, so it's very unusual that we want any more than one JConsole up at a time, and certainly not one monitoring 100 systems. This would presumably cause us memory and CPU problems anyway. Playing with how the JConsole lauches when multiple connections are supplied looks like it would give us usage difficulties anyway.
I'll have to be happy launching the console individually via Runtime.exec() for now but thanks for your reply, Luis-Miguel.