通过jmx

时间:2016-04-25 13:22:33

标签: jmx nagios hornetq

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

./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好的   HeapMemoryUsage.used = 189815504 {致力于= 534773760; INIT = 536870912;最大= 956301312;用于= 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.access$300(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$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.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$64(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”?

1 个答案:

答案 0 :(得分:0)

我最终想出了这个作品:

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