本文共 4808 字,大约阅读时间需要 16 分钟。
安装方法:自己百度
步骤如下:
# rpm -i https://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm --导入zabbix官方repo和key证书# yum -y install java-1.8.0 Zabbix-Java-gateway
zabbix-server的环境:
--Zabbix-Server:[root@harbor bin]# ./version.sh Using CATALINA_BASE: /usr/local/tomcat8Using CATALINA_HOME: /usr/local/tomcat8Using CATALINA_TMPDIR: /usr/local/tomcat8/tempUsing JRE_HOME: /usr/local/jdk1.8.0_181Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jarServer version: Apache Tomcat/8.0.53Server built: Jun 29 2018 14:42:45 UTCServer number: 8.0.53.0OS Name: LinuxOS Version: 3.10.0-862.9.1.el7.x86_64Architecture: amd64JVM Version: 1.8.0_181-b13JVM Vendor: Oracle Corporation
--配置监听zabbix_java_gateway
[root@zabbix-server ~]# egrep -v '^#|^$' /etc/zabbix/zabbix_java_gateway.conf LISTEN_IP="0.0.0.0"LISTEN_PORT=10052PID_FILE="/var/run/zabbix/zabbix_java.pid"START_POLLERS=5
--配置zabbix-server.con配置文件连接zabbix_java_gateway
[root@zabbix-server ~]# egrep -v '^#|^$' /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0PidFile=/var/run/zabbix/zabbix_server.pidSocketDir=/var/run/zabbixDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123**JavaGateway=127.0.0.1JavaGatewayPort=10052**StartJavaPollers=3SNMPTrapperFile=/var/log/snmptrap/snmptrap.logTimeout=4AlertScriptsPath=/usr/lib/zabbix/alertscriptsExternalScripts=/usr/lib/zabbix/externalscriptsFpingLocation=/usr/sbin/fpingLogSlowQueries=3000
--启动zabbix_java_gateway
[root@zabbix-server ~]# systemctl restart zabbix-java-gateway.service [root@zabbix-server ~]# [root@zabbix-server ~]# lsof -i:10052COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEjava 2251 zabbix 13u IPv6 1587393 0t0 TCP *:10052 (LISTEN)
--重启zabbix-server让配置生效
[root@zabbix-server ~]# systemctl restart zabbix-server.service [root@zabbix-server ~]# lsof -i:10051COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEzabbix_se 2320 zabbix 5u IPv4 1588014 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2320 zabbix 6u IPv6 1588015 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2325 zabbix 5u IPv4 1588014 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2325 zabbix 6u IPv6 1588015 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2326 zabbix 5u IPv4 1588014 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2326 zabbix 6u IPv6 1588015 0t0 TCP *:zabbix-trapper (LISTEN)zabbix_se 2327 zabbix 5u IPv4 1588014 0t0 TCP *:zabbix-trapper (LISTEN
--至此zabbix-server端已经部署完成
--tomcat or jdk version:[root@harbor bin]# ./version.sh Using CATALINA_BASE: /usr/local/tomcat8Using CATALINA_HOME: /usr/local/tomcat8Using CATALINA_TMPDIR: /usr/local/tomcat8/tempUsing JRE_HOME: /usr/local/jdk1.8.0_181Using CLASSPATH: /usr/local/tomcat8/bin/bootstrap.jar:/usr/local/tomcat8/bin/tomcat-juli.jarServer version: Apache Tomcat/8.0.53Server built: Jun 29 2018 14:42:45 UTCServer number: 8.0.53.0OS Name: LinuxOS Version: 3.10.0-862.9.1.el7.x86_64Architecture: amd64JVM Version: 1.8.0_181-b13JVM Vendor: Oracle Corporation
修改tomcat家目录下的bin目录下的catalina.sh文件,添加以下内容
# vim /usr/local/tomcat8/bin/catalina.sh CATALINA_OPTS="-Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.authenticate=false-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.port=12345 --监听的端口-Djava.rmi.server.hostname=192.168.22.8" -zabbix-server服务器ip
下载两个war包放到tomcat家目录下,用于监听用
--用于测试是否能获取数据用; --用于收集tomcat信息用,注意版本一定要和tomcat版本一致。--注意重启tomcat,确定12345端口已监听
### 执行以下命令,看能否收集到数据[root@harbor ROOT]# java -jar cmdline-jmxclient-0.10.3.jar - localhost:12345 java.lang:type=Memory NonHeapMemoryUsage08/03/2018 13:36:02 +0800 org.archive.jmx.Client NonHeapMemoryUsage: committed: 31653888init: 2555904max: -1used: 30516656
[root@zabbix-server ~]# wget https://github.com/liuyjishg/DevOps/blob/master/zabbix/JVM_Tomcat_Template.zip--2018-08-03 13:58:22-- https://github.com/liuyjishg/DevOps/blob/master/zabbix/JVM_Tomcat_Template.zip正在解析主机 github.com (github.com)... 13.250.177.223, 13.229.188.59, 52.74.223.119正在连接 github.com (github.com)|13.250.177.223|:443... 已连接。已发出 HTTP 请求,正在等待回应... 200 OK长度:未指定 [text/html]正在保存至: “JVM_Tomcat_Template.zip” [ <=> ] 41,216 3.23KB/s 用时 12s 2018-08-03 13:58:42 (3.23 KB/s) - “JVM_Tomcat_Template.zip” 已保存 [41216]
解压JVM_Tomcat_Template.zip文件,将里面的文件导入到zabbix模板中
再添加监控jmx就可以了
转载于:https://blog.51cto.com/passed/2154095