在server.zabbix.com中我们在编译时已经添加--enabled-java选项并布置好了java环境所以不再做过多描述
一、配置java网关
[root@server ~]# cd /usr/local/zabbix/sbin/zabbix_java/
[root@server zabbix_java]# ls
bin lib settings.sh shutdown.sh startup.sh
[root@server zabbix_java]# vim settings.sh
9 LISTEN_IP="0.0.0.0"
17 LISTEN_PORT=10052
27 PID_FILE="/tmp/zabbix_java.pid"
35 START_POLLERS=5
[root@server zabbix_java]# cd
[root@server ~]# vim /usr/local/zabbix/etc/zabbix_server.conf #末行追加
JavaGateway=127.0.0.1
JavaGatewayPort=10052
StartJavaPollers=5
[root@server ~]# sh /usr/local/zabbix/sbin/zabbix_java/startup.sh #启动配置脚本
[root@server ~]# netstat -anpt | grep 10052 #查看10052端口装态 启动成功
tcp6 0 0 :::10052 :::* LISTEN 19451/java
二、安装tomcat
tomcat源码包提取链接:https://pan.baidu.com/s/11ectXLVaSzmQs4tuspZKSw?pwd=2hye
提取码:2hye
[root@server ~]# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
[root@server ~]# javac -version
javac 1.8.0_91
[root@server ~]# which java
/usr/local/java/bin/java
[root@server ~]# tar xf apache-tomcat-8.5.16.tar.gz
[root@server ~]# mv apache-tomcat-8.5.16 /usr/local/tomcat/
三、修改tomcat启动脚本
[root@server ~]# vim /usr/local/tomcat/bin/catalina.sh
#!/bin/sh #添加如下信息CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote #启用远程监控
JMX-Dcom.sun.management.jmxremote.port=12345 #jmx远程端口,Zabbix添加时必须一致
-Dcom.sun.management.jmxremote.authenticate=false #不开启用户密码认证
-Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.2.20" #运行tomcat服务IP(不要填写错了)
四、启动tomcat
[root@server ~]# /usr/local/tomcat/bin/catalina.sh start
[root@server ~]# netstat -anpt | grep LISTEN | grep java
tcp6 0 0 :::1028 :::* LISTEN 31310/java
tcp6 0 0 :::10052 :::* LISTEN 19451/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 31310/java
tcp6 0 0 :::8009 :::* LISTEN 31310/java
tcp6 0 0 :::17806 :::* LISTEN 31310/java
tcp6 0 0 :::8080 :::* LISTEN 31310/java
tcp6 0 0 :::12345 :::* LISTEN 31310/java
五、Zabbix-web端配置
添加JMX信息
导入模板
模板提取链接:https://pan.baidu.com/s/1KQeNlQAphVp7RQNhOSQT5Q?pwd=l3yp
提取码:l3yp
为server.zabix.com添加模板
等待一会效果如下(1-2分钟)
如变红色 查看在tomcat的启动脚本中配置的端口后是否启动 为下面状态
[root@agent ~]# netstat -antp | grep java
tcp6 0 0 :::21406 :::* LISTEN 11385/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 11385/java
tcp6 0 0 :::8009 :::* LISTEN 11385/java
tcp6 0 0 :::8080 :::* LISTEN 11385/java
tcp6 0 0 :::25464 :::* LISTEN 11385/java
tcp6 0 0 :::12345 :::* LISTEN 11385/java
tcp6 0 0 192.168.200.112:12345 192.168.200.111:39274 ESTABLISHED 11385/java #如果没有就重启一下tomcat
tcp6 0 0 192.168.200.112:21406 192.168.200.111:26844 ESTABLISHED 11385/java
tcp6 0 0 192.168.200.112:21406 192.168.200.111:26846 ESTABLISHED 11385/java
查看tomcat出图情况
文章来源:https://www.toymoban.com/news/detail-606879.html
其他JVM项出垃圾回收均可出图文章来源地址https://www.toymoban.com/news/detail-606879.html
到了这里,关于zabbix通过JMX监控tomcat的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!