Skip to content
Advertisement

Viewing MBeans through jstatd

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?

Advertisement

Answer

jstatd has nothing to do with JMX. Jstatd is a proxy for Jvmstat. To get MBeans and CPU usage you need to also enable JMX. See JMX Remote Monitoring and Management for more details. Once you have JMX enabled, VisualVM will automatically detect (via jvmstat) that it can also use JMX and it will display data from both jvmstat and JMX in one place.

2 People found this is helpful
Advertisement