1.修改jmx的配置


2.tomcat开启jmx功能

agent配置tomcat

JMX Remote jar 二进制包,放在 tomcat/lib 下面.

修改 tomcat server.xml 配置文件

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="12345" rmiServerPortPlatform="12346" />


Download catalina-jmx-remote.jar into your zabbix_java/lib/ directory too, or you will run into class not found exceptions.

May be you need to restart zabbix_java


修改 tomcat/bin 目录下 catalina.sh 

CATALINA_OPTS="

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.authenticate=false 

-Dcom.sun.management.jmxremote.ssl=false 

-Djava.rmi.server.hostname=172.16.103.134"


3.zabbix开启监控java功能


agent上配置zabbix_java  (抓取agent上tomcat的jmx的数据)

在zabbix的安装包里面

./configure --enable-java --prefix=/opt/zabbix_java

make && make install


agent

vim /opt/zabbix_java/sbin/zabbix_java/settings.sh

LISTEN_IP="0.0.0.0"

LISTEN_PORT=10052

PID_FILE="/tmp/zabbix_java.pid"

START_POLLERS=5


./startup.sh


监控server

vim /usr/local/zabbix/etc/zabbix_server.conf

JavaGateway=X.X.X.X  (127.0.0.1   server端也得开启zabbix_java,多个tomcat应用监控时再测试)

JavaGatewayPort=10052

StartJavaPollers=5


测试用的命令行

java -jar cmdline-jmxclient-0.10.3.jar - X.X.X.X:12345 java.lang:type=Memory NonHeapMemoryUsage


java -jar cmdline-jmxclient-0.10.3.jar - X.X.X.X:12345 Catalina:context=/,host=ame_app1,type=Manager maxActive


java -jar cmdline-jmxclient-0.10.3.jar - X.X.X.X:12345 'Catalina:name="ajp-apr-8009",type=GlobalRequestProcessor' bytesReceived