一、Tomcat 部署 Jmxtrans-Agent
1、解压 jmxtrans-agent.rar 到目录 应用系统安装目录;以Tomcat 7.x 为例目录结构如下图:
2、展开 jmxtrans-agent 目录。可见如下结构:
3、进入 服务监控配置 目录,复制相应Web容器对应版本的配置,到自己的Web容器下面比如Tomcat 7.x 将 bin目录下的文件拷贝至Tomcat 7.x 下的bin目录中去;
特别注意:
a、此处的setenv.bat / setenv.sh 脚本是针对Tomcat专门写的
b、Tomcat官方建议修改Tomcat内存等参数也应该在setenv.bat / setenv.sh文件中;故此处有修改内存
c、删除 catalina.bat / catalina.sh 中添加的内存调整参数;以后统一采用setenv.bat / setenv.sh文件进行调整
export JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/jmxtrans-agent-1.2.10.jar=jmxtrans-agent.xml"
- java代理jar路径可以相对于工作目录
- jmxtrans-agent.xml是配置文件,可以是相对于类路径(classpath:…),http(s)(http(s)://…)或基于文件系统的(相对于工作目录)
Tomcat 专用的 jmxtrans-agent.xml 简单示例
<jmxtrans-agent>
<queries>
<!-- OS -->
<query objectName="java.lang:type=OperatingSystem" attribute="SystemLoadAverage" resultAlias="os.systemLoadAverage"/>
<!-- JVM -->
<query objectName="java.lang:type=Memory" attribute="HeapMemoryUsage" key="used"
resultAlias="jvm.heapMemoryUsage.used"/>
<query objectName="java.lang:type=Memory" attribute="HeapMemoryUsage" key="committed"
resultAlias="jvm.heapMemoryUsage.committed"/>
<query objectName="java.lang:type=Memory" attribute="NonHeapMemoryUsage" key="used"
resultAlias="jvm.nonHeapMemoryUsage.used"/>
<query objectName="java.lang:type=Memory" attribute="NonHeapMemoryUsage" key="committed"
resultAlias="jvm.nonHeapMemoryUsage.committed"/>
<query objectName="java.lang:type=ClassLoading" attribute="LoadedClassCount" resultAlias="jvm.loadedClasses"/>
<query objectName="java.lang:type=Threading" attribute="ThreadCount" resultAlias="jvm.thread"/>
<!-- TOMCAT -->
<query objectName="Catalina:type=GlobalRequestProcessor,name=*" attribute="requestCount"
resultAlias="tomcat.requestCount"/>
<query objectName="Catalina:type=GlobalRequestProcessor,name=*" attribute="errorCount"
resultAlias="tomcat.errorCount"/>
<query objectName="Catalina:type=GlobalRequestProcessor,name=*" attribute="processingTime"
resultAlias="tomcat.processingTime"/>
<query objectName="Catalina:type=GlobalRequestProcessor,name=*" attribute="bytesSent"
resultAlias="tomcat.bytesSent"/>
<query objectName="Catalina:type=GlobalRequestProcessor,name=*" attribute="bytesReceived"
resultAlias="tomcat.bytesReceived"/>
<!-- APPLICATION -->
<query objectName="Catalina:type=Manager,context=/,host=localhost" attribute="activeSessions"
resultAlias="application.activeSessions"/>
</queries>
<outputWriter class="org.jmxtrans.agent.GraphitePlainTextTcpOutputWriter">
<host>localhost</host>
<port>2003</port>
<namePrefix>app_123456.servers.i876543.</namePrefix>
</outputWriter>
<outputWriter class="org.jmxtrans.agent.ConsoleOutputWriter"/>
<collectIntervalInSeconds>20</collectIntervalInSeconds>
</jmxtrans-agent>
作者:Jeebiz 创建时间:2020-10-20 09:56
更新时间:2024-02-26 11:18
更新时间:2024-02-26 11:18