我正在尝试使用percona cacti图监视tomcat应用程序。该应用程序使用Windows中的jconsole。主机是centos 6.6 64位,我安装了蚂蚁。
当我尝试运行percona给出的示例时,它对我不起作用。
[root@titan ~]# ant -Djmx.server.port=12345 -e -q -f jmx-monitor.xml -v
Apache Ant(TM) version 1.9.4 compiled on April 29 2014
Buildfile: /root/jmx-monitor.xml
Detected Java version: 1.7 in: /usr/java/jdk1.7.0_05/jre
Detected OS: Linux
parsing buildfile /root/jmx-monitor.xml with URI = file:/root/jmx-monitor.xml
Project base dir set to: /root
parsing buildfile jar:file:/opt/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/opt/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Override ignored for property "jmx.server.port"
Build sequence for target(s) `status' is [status]
Complete build sequence is [status, ]
status:
parsing buildfile jar:file:/root/.ant/lib/catalina-ant.jar!/org/apache/catalina/ant/jmx/antlib.xml with URI = jar:file:/root/.ant/lib/catalina-ant.jar!/org/apache/catalina/ant/jmx/antlib.xml from a zip file
parsing buildfile jar:file:/opt/ant/lib/catalina-ant.jar!/org/apache/catalina/ant/jmx/antlib.xml with URI = jar:file:/opt/ant/lib/catalina-ant.jar!/org/apache/catalina/ant/jmx/antlib.xml from a zip file
Property "jmx.catalina.threadpool.name" has not been set
BUILD FAILED
/root/jmx-monitor.xml:54: javax.management.InstanceNotFoundException: Catalina:type=ThreadPool,name=${jmx.catalina.threadpool.name}
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:1464)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
at javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:657)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
at sun.rmi.transport.Transport$2.run(Transport.java:202)
at sun.rmi.transport.Transport$2.run(Transport.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:198)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:567)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.access$400(TCPTransport.java:619)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:684)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$1.run(TCPTransport.java:681)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:681)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:160)
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:901)
at org.apache.catalina.ant.jmx.JMXAccessorGetTask.jmxGet(JMXAccessorGetTask.java:138)
at org.apache.catalina.ant.jmx.JMXAccessorGetTask.jmxExecute(JMXAccessorGetTask.java:123)
at org.apache.catalina.ant.jmx.JMXAccessorTask.execute(JMXAccessorTask.java:348)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 1 second
我注意到我必须从jmx-monitor.xml
中移除以下内容才能使其正常工作。
<jmx:get
name="Catalina:type=ThreadPool,name=${jmx.catalina.threadpool.name}"
attribute="currentThreadsBusy"
resultproperty="currentThreadsBusy"
/>
<jmx:get
name="Catalina:type=ThreadPool,name=${jmx.catalina.threadpool.name}"
attribute="currentThreadCount"
resultproperty="currentThreadCount"
/>
<jmx:get
name="Catalina:type=ThreadPool,name=${jmx.catalina.threadpool.name}"
attribute="maxThreads"
resultproperty="maxThreads"
/>
current_threads_busy: ${currentThreadsBusy}
current_thread_count: ${currentThreadCount}
max_threads: ${maxThreads}
如果不删除上述内容,我将如何使用它。以下命令由cati运行
ant -Djmx.server.port=9012 -Djmx.catalina.threadpool.name=http-8080 -e -q -f jmx-monitor.xml
答案 0 :(得分:1)
根据您的工作,我刚刚将以下行添加到jmx-monitor.xml。
<property name="jmx.catalina.threadpool.name" value="http-8080" />
它有效。
ant -Djmx.server.port=12345 -e -q -f jmx-monitor.xml -v
或者只需通过以下命令进行测试。 (我认为http://www.percona.com/doc/percona-monitoring-plugins/1.1/cacti/jmx-templates.html)
中的文档并不好ant -Djmx.server.port=9012 -e -q -f jmx-monitor.xml -Djmx.catalina.threadpool.name=http-8080