1、開啟jmx
a、單實例
#vim $CATALINA_HOME/bin/catalina.sh #填寫如下代碼
CATALINA_OPTS="
-Dcom.sun.management.jmxremote #開啟遠程
-Dcom.sun.management.jmxremote.port=10001 #監(jiān)聽端口,如果tomcat是單機多實例,不要添加此項
-Dcom.sun.management.jmxremote.ssl=false #不使用ssl鏈接
-Dcom.sun.management.jmxremote.authenticate=false" #不開啟用戶密碼認證
b.單機多實例
tomcat單機多實例在對應的實例conf/server.xml添加
<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />
#10001為遠程端口 10002為獲取數(shù)據(jù)端口
#org.apache.catalina.mbeans.JmxRemoteLifecycleListener需要catalina-jmx-remote.jar支持
#wget -O $CATALINA_HOME/lib/catalina-jmx-remote.jar http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.37/bin/extras/catalina-jmx-remote.jar
官網(wǎng)參考文檔http://tomcat.apache.org/tomcat-8.5-doc/config/listeners.html#JMX_Remote_Lifecycle_Listener_-_org.apache.catalina.mbeans.JmxRemoteLifecycleListener
2、下載并解壓編譯好的release包 到目標安裝目錄下
#wget https://github.com/toomanyopenfiles/jmxmon/releases/download/v0.0.2/jmxmon-v0.0.2.tar.gz
#tar zxf jmxmon-v0.0.2.tar.gz -C /usr/local/open-falcon/
#cd /usr/local/open-falcon/jmxmon-v0.0.2
#cp conf.example.properties conf.properties
#vim conf.properties #配置jmx端口
jmx.ports=10001
3、測試
a.重啟tomcat,讓jmx開啟生效
b.啟用監(jiān)控插件
#sh control start
#cat var/app.log #查看日志是否正常采集數(shù)據(jù)
2019-01-17 15:52:13,638 [pool-1-thread-1] INFO [com.stephan.tof.jmxmon.JMXMonitor] - post status=200, post url=http://localhost:1988/v1/push, content=[*}]
c. 配置說明
配置文件默認文件名為conf.properties,內(nèi)容說明如下:
# 工作目錄用來存放jmxmon的臨時緩存文件,注意不要修改此目錄下的文件
workDir=./
# 需要監(jiān)聽的本地jmx端口,支持監(jiān)聽多個端口,多端口用逗號分隔
jmx.ports=10000,10001,10002,10003
# 本地agent的上報url,如果使用open-falcon的默認配置,則這里不需要改變
agent.posturl=http://localhost:1988/v1/push
# 可選項:上報給open-falcon的endpoint,默認值為本機hostname。不建議修改
#hostname=
# 可選項:上報給open-falcon的上報間隔,默認值60,單位秒。不建議修改
#step=
open-falcon安裝參考: