1、开启jmx
a、单实例
#vim $CATALINA_HOME/bin/catalina.sh #填写如下代码
CATALINA_OPTS="
-Dcom.sun.management.jmxremote #开启远程
-Dcom.sun.management.jmxremote.port=10001 #监听端口,如果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为获取数据端口
#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
官网参考文档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.启用监控插件
#sh control start
#cat var/app.log #查看日志是否正常采集数据
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,内容说明如下:
# 工作目录用来存放jmxmon的临时缓存文件,注意不要修改此目录下的文件
workDir=./
# 需要监听的本地jmx端口,支持监听多个端口,多端口用逗号分隔
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安装参考: