zabbix提供了一个java gateway的应用去监控jmx(Java Management Extensions,即Java管理扩展)是一个为应用程序、设备、系统等植入管理功能的框架。JMX可以跨越一系列异构操作系统平台、系统体系结构和网络传输协议,灵活的开发无缝集成的系统、网络和服务管理应用。

下面为部署步凑:

1、zabbix server安装java gateway

1234567891011[root@localhost ~]# yum install -y  java  java-devel  zabbix-java-gateway [root@localhost ~]# java -versionopenjdk version "1.8.0_161"OpenJDK Runtime Environment (build 1.8.0_161-b14)OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)[root@localhost ~]# service zabbix-java-gateway statusRedirecting to /bin/systemctl status zabbix-java-gateway.service● zabbix-java-gateway.service - Zabbix Java GatewayLoaded: loaded (/usr/lib/systemd/system/zabbix-java-gateway.service; disabled; vendor preset: disabled)Active: inactive (dead)

2、添加java环境

1234567891011[root@localhost ~]# vim /etc/profile JAVA_HOME=/usr/java/jdk1.8.0_161PATH=$JAVA_HOME/bin:$PATHCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOMEexport PATHexport CLASSPATH #加载环境[root@localhost ~]# source /etc/profile

3、修改java-gateway配置文件

12345678910111213141516[root@localhost ~]# grep ^[a-Z] /etc/zabbix/zabbix_java_gateway.conf #监控地址LISTEN_IP="0.0.0.0" #监听端口LISTEN_PORT=10052 #进程文件路径PID_FILE="/var/run/zabbix/zabbix_java.pid" #开启的工作线程数START_POLLERS=5 #超时TIMEOUT=3

 4、重启java-gateway服务

1[root@localhost ~]# systemctl restart zabbix-java-gateway

5、修改zabbix_server配置文件

12345678[root@localhost ~]# vim /etc/zabbix/zabbix_java_gateway# JavaGateway的服务器IP地址JavaGateway=192.168.247.133<br># JavaGateway的服务端口JavaGatewayPort=10052<br># 从javaGateway采集数据的进程数StartJavaPollers=5 

6、重启zabbix_server服务

1[root@localhost ~]# systemctl restart zabbix-server

7、客户端配置

1234567891011121314在tomcat下的/bin/catalina.sh文件中添加以下内容: CATALINA_OPTS="$CATALINA_OPTS-Djavax.management.builder.initial=-Dcom.sun.management.jmxremote=true-Dcom.sun.management.jmxremote.port=12345  -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false-Djava.rmi.server.hostname=192.168.247.132"               //tomcat客户端ip 重启tomcat进程: [root@localhost bin]# ./shutdown.sh[root@localhost bin]# ./startup.sh

下面添加到zabbix监控中

 选择配置:主机-模板-选择-模板-:
Template APP Apache Tomcat JMX
Template APP Generic Java JMX

主机–JMX接口

查看图形

Leave a Reply

Your email address will not be published. Required fields are marked *