I am trying to monitor all Java processes running on a server via jstatd. I've got it set up enough that I can connect with VisualVM and see all running processes. Most displays work fine, however certain things (especially CPU usage and MBeans) do not display. Instead, it says:
MBeans Browser
Data not available because JMX connection to the JMX agent could not be established.
I assumed that the problem was that the application must "announce" through the jstatd
RMI registry rather than a local one, so I tried out the following (per these suggestions) but it still won't display. The code I tried is as follows:
public class JmxRmiConnectorTest {
public static void main(String[] args) throws Exception {
Registry rmiRegistry = LocateRegistry.createRegistry(9994);
String svc =
"service:jmx:rmi://localhost:9994/jndi/rmi://localhost:1099/connector";
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL url = new JMXServiceURL(svc);
RMIConnectorServer rmiServer = new RMIConnectorServer(url, null, mbeanServer);
rmiServer.start();
Thread.sleep(100000);
rmiServer.stop();
}
}
How can I get my MBeans and CPU usage to show up in VisualVM when seen through jstatd?