Zabbix使用JMX监控tomcat
1.安装tomcat和jdk
[[email protected] ~]# ls
apache-tomcat-8.5.24.tar.gz jdk-8u121-linux-x64.rpm zabbix-agent-4.0.5-1.el7.x86_64.rpm
[[email protected] ~]# rpm -ivh jdk-8u121-linux-x64.rpm
[[email protected] ~]# tar zxf apache-tomcat-8.5.24.tar.gz -C /usr/local
[[email protected] ~]# cd /usr/local
[[email protected] local]# ls
apache-tomcat-8.5.24 bin etc games include lib lib64 libexec sbin share src
2.制作软连接
[[email protected] local]# ln -s apache-tomcat-8.5.24/ tomcat
[[email protected] local]# ls
apache-tomcat-8.5.24 etc include lib64 sbin src
bin games lib libexec share tomcat
[[email protected] local]# cd tomcat/
[[email protected] tomcat]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[[email protected] tomcat]# cd bin/
[[email protected] bin]# ls
3.向tomcat中添加JVM的参数
[[email protected] bin]# vim catalina.sh
110 CATALINA_OPTS='-Dcom.sun.management.jmxremote
111 -Dcom.sun.management.jmxremote.port=8888
112 -Dcom.sun.management.jmxremote.ssl=false
113 -Dcom.sun.management.jmxremote.authenticate=false'
[[email protected] bin]# ./startup.sh
[[email protected] bin]# netstat -tnlp
4.server1: 安装zabbix_java_gateway并做相应的配置
[[email protected] ~]# cd 4.0/
[[email protected] 4.0]# ls
[[email protected] 4.0]# yum install -y zabbix-java-gateway-4.0.5-1.el7.x86_64.rpm
[[email protected] 4.0]# cd /etc/zabbix/
[[email protected] zabbix]# ls
web zabbix_agentd.conf zabbix_java_gateway.conf zabbix_server.conf
zabbix_agentd. zabbix_agentd.d zabbix_java_gateway_logback.xml
[[email protected] zabbix]# vim zabbix_java_gateway.conf ##查看一下
[[email protected] zabbix]# vim zabbix_server.conf ##修改内容如下
288 JavaGateway=172.25.19.1
296 JavaGatewayPort=10052
304 StartJavaPollers=5
5.开启服务
[[email protected] zabbix]# systemctl start zabbix-java-gateway
[[email protected] zabbix]#
[[email protected] zabbix]# netstat -tnlp
[[email protected] zabbix]# zabbix_server -R config_cache_reload
zabbix_server [12968]: command sent successfully
[[email protected] zabbix]#
[[email protected] zabbix]# systemctl restart zabbix-server
6.zabbix监控页面进行相应的配置
- 配置—> 主机—> server2—> 主机—> 添加JMX接口的信息(端口要和配置文件中写的一样) —> 添加
- 主机 —> 模板—> 选择图中的模板 —> 添加 —> 更新
- server2 —> 图形—> file descriptors—> 预览
- 刷新以下可以看到server2的JMX变绿