1、開啟jmx
a、單實(shí)例
#vim $CATALINA_HOME/bin/catalina.sh #填寫如下代碼
CATALINA_OPTS="
-Dcom.sun.management.jmxremote #開啟遠(yuǎn)程
-Dcom.sun.management.jmxremote.port=10001 #監(jiān)聽端口,如果tomcat是單機(jī)多實(shí)例,不要添加此項(xiàng)
-Dcom.sun.management.jmxremote.ssl=false #不使用ssl鏈接
-Dcom.sun.management.jmxremote.authenticate=false" #不開啟用戶密碼認(rèn)證
b.單機(jī)多實(shí)例
tomcat單機(jī)多實(shí)例在對(duì)應(yīng)的實(shí)例conf/server.xml添加
<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />
#10001為遠(yuǎn)程端口 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包 到目標(biāo)安裝目錄下
#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、測(cè)試
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. 配置說明
配置文件默認(rèn)文件名為conf.properties,內(nèi)容說明如下:
# 工作目錄用來存放jmxmon的臨時(shí)緩存文件,注意不要修改此目錄下的文件
workDir=./
# 需要監(jiān)聽的本地jmx端口,支持監(jiān)聽多個(gè)端口,多端口用逗號(hào)分隔
jmx.ports=10000,10001,10002,10003
# 本地agent的上報(bào)url,如果使用open-falcon的默認(rèn)配置,則這里不需要改變
agent.posturl=http://localhost:1988/v1/push
# 可選項(xiàng):上報(bào)給open-falcon的endpoint,默認(rèn)值為本機(jī)hostname。不建議修改
#hostname=
# 可選項(xiàng):上報(bào)給open-falcon的上報(bào)間隔,默認(rèn)值60,單位秒。不建議修改
#step=

open-falcon安裝參考:


