*
The moose likes Other JSE/JEE APIs and the fly likes Setting JMX Options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Setting JMX Options " Watch "Setting JMX Options " New topic
Author

Setting JMX Options

pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Hi All,

I have a JMX monitoring tool which monitors java applications that have these options set while running them



My Quesiton is could these options be set from the code itself? something like this



Thanks
Pradeep


[<a href="http://cyvis.sourceforge.net" target="_blank" rel="nofollow">CyVis - Software Complexity Visualiser</a>] [<a href="http://pradeepselvaraj.blogspot.com" target="_blank" rel="nofollow">Pradeep's Blog</a>]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
I'm not sure if it works -of course it's easy to try- but if so, you need to leave out the "-D" in the name of the property.


Ping & DNS - my free Android networking tools app
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

Originally posted by Ulf Dittmer:
I'm not sure if it works -of course it's easy to try- but if so, you need to leave out the "-D" in the name of the property.


Agreed... just try it. But it is unlikely that it will work. I think the Java 5 mbean server is created, along with the RMI connector (that you are trying to configure), before the main method is called.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Thanks ,

Is there a way to monitor non Java programs through java? I mean i have a JMX Monitoring program, so my plan was to start the non java programs using java, and then notify JMX somehow.

This is how i started a non java app...



Something like the one above is what i would prefer. The other way that i am doing it now is to set the JMX options for this program while running it. But with such a method i would have to run an instance of this program for each non java application that i monitor(with the -Dcom.sun.management.jmxremote argument passed to the VM) which is not a nice solution.

Whatz the best way to do this with my monitoring tool?

Thanks again,
Pradeep
[ March 22, 2007: Message edited by: pradeep selvaraj ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41124
    
  45
Note that the J in JMX stands for Java. You can't use it for monitoring non-Java applications.
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Yeah. I know that, but it was only for knowing if the application is running or not. Not like what we get in JConsole.

Pradeep
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

The default set of mbeans that come with the JDK 5 mbean server does not include a version that monitor processes, but it should not be hard to write one.

Basically, you have to create the monitoring code (probably using runtime.exec() calls to tasklist), and then create an mbean that uses this library that provides a JMX interface to your application.

Henry
pradeep selvaraj
Ranch Hand

Joined: Nov 29, 2005
Posts: 62
Henry,
Could you please explain it a bit more.

Thanks
Pradeep
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18532
    
  40

Originally posted by pradeep selvaraj:
Henry,
Could you please explain it a bit more.

Thanks
Pradeep


Basically, in windows, you can use the "tasklist" command to monitor what proceses are running. And in unix/linux, you can use the "ps" command to monitor what processes are running. "tasklist" is fully documented on the microsoft site, and you can do a "man ps" for "ps".

Anyway, from Java, you may call out to the operating system commands with the Runtime.exec() set of methods.

Henry
 
jQuery in Action, 2nd edition
 
subject: Setting JMX Options
 
Similar Threads
help with jconsole
Tomcat monitoring
Memory/CPU/timing resources from Java Program
Activating JMX for tomcat 5.5.9 on As/400 iseries
Database Monitoring