• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting JMX Options

 
pradeep selvaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Henry Wong
author
Marshal
Pie
Posts: 21116
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
pradeep selvaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that the J in JMX stands for Java. You can't use it for monitoring non-Java applications.
 
pradeep selvaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21116
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry,
Could you please explain it a bit more.

Thanks
Pradeep
 
Henry Wong
author
Marshal
Pie
Posts: 21116
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic