JMX - 如何监视应用程序的本地和远程CPU使用情况

时间:2016-11-21 14:08:38

标签: java jmx monit

Host : serverhost.example.com / 127.0.0.1
Port : 8082
API/Application : Google Chrome / Tomcat deployed application
Monitor : CPU = 35%
          Memory = 30%

这是我的代码段:

String url = "service:jmx:rmi:///jndi/rmi://127.0.0.1:8082/jmxrmi";
JMXConnector jmxc = null;
try {
    JMXServiceURL jmxSvcUrl = new JMXServiceURL(url);
    System.out.println("~~~~~~~~~~~1~~~~~~~~~~~~~~");
    jmxc = JMXConnectorFactory.connect(jmxSvcUrl, null);
    System.out.println("~~~~~~~~~~~2~~~~~~~~~~~~~~");
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    String domains[] = mbsc.getDomains();
    Arrays.sort(domains);
    for (String domain : domains) {
        System.out.println( domain );
    }
    System.out.println("~~~~~~~~~~~3~~~~~~~~~~~~~~");

}catch(Exception ex){
    ex.printStackTrace();
}finally {
    if( jmxc != null )
        try{jmxc.close();}catch(Exception ex){;}
}

我收到了这个错误

java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.net.SocketTimeoutException: Read timed out]
    at javax.management.remote.rmi.RMIConnector.connect(Unknown Source)
    at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
    at com.ms3.health.core.ResourceManagement.jmxSvcUrl(ResourceManagement.java:137)
    at com.ms3.health.core.ResourceManagement.main(ResourceManagement.java:201)
Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.net.SocketTimeoutException: Read timed out]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(Unknown Source)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(Unknown Source)
    at javax.management.remote.rmi.RMIConnector.findRMIServer(Unknown Source)
    ... 4 more
Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: 
    java.net.SocketTimeoutException: Read timed out
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.newCall(Unknown Source)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    ... 9 more
Caused by: java.net.SocketTimeoutException: Read timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at java.io.DataInputStream.readByte(Unknown Source)
    ... 13 more

请参阅我的代码段以获取更多详细信息。感谢和更多的力量给每个人。 请让我了解我的问题的原因以及如何处理它。 有关更多详细信息,请参阅我的代码段。感谢和更多的力量给每个人。 请让我了解我的问题的原因以及如何处理它。

0 个答案:

没有答案