I have a Java process running on a remote machine, and the process sets up some mbeans. I also have jstatd
running on that machine as the same user as the Java process. (The mbeans can be set up programmatically or using -Dcom.sun.management.jmxremote...
etc, this doesn't appear to make a difference).
VisualVM is able to make a jstatd
connection to the process, which it discovers automatically, but this means I don't get access to mbeans or, for example, the CPU history chart. Alternatively I can create an explicit JMX connection, which gives me the usual range of useful tools, but I want for the application to be assigned a random JMX port when it starts, this config can't be static.
Is there any way to get VisualVM to auto-connect to my process via JMX? This would require it to auto-discover the JMX ports, but I would have thought jstatd
could do that. Does anyone know of any plugins for visualvm to automate this?
Unfortunately there is no way to assign random JMX port to the remote application. You can start your remote application with
-Dcom.sun.management.jmxremote.port=<fixed port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
and VisualVM will be able to read this configuration via Jvmstat (provide by jstatd) and open JMX connection to your remote application automatically. So you need to assign fixed port(s) to your remote application(s). Once you have it, everything will work fine and VisualVM will automatically connect to your application via JMX (in fact it will combine data from both Jvmstat and JMX).