zabbix 3.0 利用jmx监控 tomcat
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 3.0 利用jmx监控 tomcat相关的知识,希望对你有一定的参考价值。
zabbix-server端的配置
注意编译安装zabbix-server的时候,带上参数 --enable-java .
注意,由于你是编译zabbix-java-gateway,所以,你的zabbix服务器是必须要有java环境的。
如何安装jdk环境?请看这篇:http://duanyexuanmu.blog.51cto.com/1010786/1751156
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh2 --enable-java
修改java的settings.sh参数,
LISTEN_IP="0.0.0.0"
LISTEN_PORT=10052
START_POLLERS=5
# This is a configuration file for Zabbix Java Gateway. # It is sourced by startup.sh and shutdown.sh scripts. ### Option: zabbix.listenIP # IP address to listen on. # # Mandatory: no # Default: LISTEN_IP="0.0.0.0" ### Option: zabbix.listenPort # Port to listen on. # # Mandatory: no # Range: 1024-32767 # Default: LISTEN_PORT=10052 ### Option: zabbix.pidFile # Name of PID file. # If omitted, Zabbix Java Gateway is started as a console application. # # Mandatory: no # Default: # PID_FILE= PID_FILE="/tmp/zabbix_java.pid" ### Option: zabbix.startPollers # Number of worker threads to start. # # Mandatory: no # Range: 1-1000 # Default: START_POLLERS=5 ### Option: zabbix.timeout # How long to wait for network operations. # # Mandatory: no # Range: 1-30 # Default: # TIMEOUT=3
修改zabbix_server.conf
LogFile=/tmp/zabbix_server.log DBName=zabbix DBUser=zabbix DBPassword=zabbix JavaGateway=127.0.0.1 JavaGatewayPort=10052 StartJavaPollers=5
都修改好以后,保存并启动java
./startup.sh
查看进程:
[[email protected] src]# netstat -tlunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1080/sshd
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 1386/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1737/zabbix_server
tcp 0 0 :::22 :::* LISTEN 1080/sshd
tcp 0 0 :::10050 :::* LISTEN 1386/zabbix_agentd
tcp 0 0 :::10051 :::* LISTEN 1737/zabbix_server
tcp 0 0 :::10052 :::* LISTEN 1994/java
tcp 0 0 :::3306 :::* LISTEN 1329/mysqld
tcp 0 0 :::80 :::* LISTEN 1376/httpd
从上我们看到,zabbix_agent,zabbix_server都已经开启,java也开启了,端口是10052
========================================================================================
Tomcat端配置
1.首先配置tomcat环境,参考这里,注意被控端和服务器端的JDK版本要一致
http://duanyexuanmu.blog.51cto.com/1010786/1755443
http://duanyexuanmu.blog.51cto.com/1010786/1751156
2.将catalina-jmx-remote.jar 下载,并复制到
/usr/local/tomcat/lib/ 目录下
3.修改TOmcat的catalina.sh文件
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.224"
注意,不要根据网上人云亦云,把ssh=false也给加上。
其中,192.168.1.224为tomcat所在PCIP地址,根据你自己的环境改边就行了,你是什么IP就填什么IP
4.修改server.xml
[[email protected] lib]# locate server.xml
/usr/local/tomcat/conf/server.xml
其中加入如下选项:
<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="12345" rmiServerPortPlatform="12345"/>
重启tomcat
====================================================================
回到 zabbix服务器:
在zabbix服务器端用工具测试
下载cmdline-jmxclient-0.10.3.jar工具
java -jar /usr/local/src/cmdline-jmxclient-0.10.3.jar - 192.168.1.224:12345 java.lang:type=Memory NonHeapMemoryUsage
11/12/2014 15:39:30 +0800 org.archive.jmx.Client NonHeapMemoryUsage:
committed: 552665088
init: 539426816
max: 587202560
used: 75002232
显示有数据,最后在zabbix添加host,填上模板就OK了。
本文出自 “清晰明了” 博客,请务必保留此出处http://duanyexuanmu.blog.51cto.com/1010786/1758027
以上是关于zabbix 3.0 利用jmx监控 tomcat的主要内容,如果未能解决你的问题,请参考以下文章