zabbix监控 JVM
在Zabbix中,JMX监控数据的获取由专门的代理程序来实现,即Zabbix-Java-Gateway来负责数据的采集,Zabbix-Java-Gateway和JMX的Java程序之间通信获取数据
JMX在zabbix中的运行流程
1.Zabbix-Server找Zabbix-Java-Gateway获取Java数据
2.Zabbix-Java-Gateway找Java程序(zabbix-agent)获取数据
3.Java程序返回数据给Zabbix-Java-Gateway
4.Zabbix-Java-Gateway返回数据给Zabbix-Server
5.Zabbix-Server进行数据展示
安装JAVA-gateway
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/
# 安装
[root@web02 ~]# rpm -ivh
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-java-gateway-5.0.42-1.el7.x86_64.rpm
# 启动java-gateway
[root@web02 ~]# systemctl start zabbix-java-gateway
# 修改zabbix_server配置文件
[root@zabbix5-server ~]# vim /etc/zabbix/zabbix_server.conf
JavaGateway=172.16.1.8
JavaGatewayPort=10052
StartJavaPollers=5
# 重启zabbix-server
[root@zabbix5-server ~]# systemctl restart zabbix-server
客户端相关配置
# 修改tomcat启动脚本
[root@web02 ~]# vim /usr/libexec/tomcat/server
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=172.16.1.8"
## 完整脚本
[root@web02 ~]# cat /usr/libexec/tomcat/server
#!/bin/bash
. /usr/libexec/tomcat/preamble
MAIN_CLASS=org.apache.catalina.startup.Bootstrap
FLAGS="$JAVA_OPTS"
OPTIONS="-Dcatalina.base=$CATALINA_BASE \
-Dcatalina.home=$CATALINA_HOME \
-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS \
-Djava.io.tmpdir=$CATALINA_TMPDIR \
-Djava.util.logging.config.file=${LOGGING_PROPERTIES} \
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12345
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=172.16.1.8"
if [ "$1" = "start" ] ; then
FLAGS="${FLAGS} $CATALINA_OPTS"
if [ "${SECURITY_MANAGER}" = "true" ] ; then
OPTIONS="${OPTIONS} \
-Djava.security.manager \
-Djava.security.policy==${CATALINA_BASE}/conf/catalina.policy"
fi
run start
elif [ "$1" = "stop" ] ; then
run stop
fi
# 重启tomcat
zabbix 页面配置