通过 jmx 检查 hornetq 上的 mbean 值

Check mbean value on hornetq through jmx

我想使用 check_jmx 找到的 nagios 插件来监视 hornetq 2.4.0 的实例 here。 在我用 ant 构建它之后,我可以这样称呼它:

./check_jmx -U service:jmx:rmi:///jndi/rmi://127.0.0.1:6000/jmxrmi -O java.lang:type=Memory -A HeapMemoryUsage -K used -I HeapMemoryUsage -J used -vvvv -w 4248302272 -c 5498760192

并得到这个输出:

JMX OK HeapMemoryUsage.used=189815504{committed=534773760;init=536870912;max=956301312;used=189815504}



但是如果我试试这个:

./check_jmx -U service:jmx:rmi:///jndi/rmi://127.0.0.1:6000/jmxrmi -O java.lang:type=MemoryPool,name="PS Eden Space" -A Usage -I Usage -K used -J used -vvv -w 4248302272 -c 5498760192

我遇到异常:

JMX CRITICAL java.lang:type=MemoryPool,name=PS connecting to java.lang:type=MemoryPool,name=PS by URL service:jmx:rmi:///jndi/rmi://192.168.9.39:6000/jmxrmijavax.management.InstanceNotFoundException: java.lang:type=MemoryPool,name=PS
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1095)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:643)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:678)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1448)
    at javax.management.remote.rmi.RMIConnectionImpl.access0(RMIConnectionImpl.java:76)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1312)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1404)
    at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:641)
    at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
    at sun.rmi.transport.Transport.run(Transport.java:200)
    at sun.rmi.transport.Transport.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run(TCPTransport.java:683)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
    at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
    at javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:903)
    at org.nagios.JMXQuery.execute(JMXQuery.java:184)
    at org.nagios.JMXQuery.main(JMXQuery.java:76)

我可以使用此工具获取该值吗?或者是否有其他工具可以获取 "PS Eden Space"?

我最终想出了这个方法:

java -cp jmxquery.jar org.nagios.JMXQuery -U service:jmx:rmi:///jndi/rmi://127.0.0.1:6000/jmxrmi -O "java.lang:type=MemoryPool,name=PS Old Gen" -A Usage -I Usage -K used  -vvv -w 4248302272 -c 5498760192