#配置zabbix服务端
#安装zabbix-java-gateway
#安装
yum -y install zabbix-java-gateway
#启动
systemctl start zabbix-java-gateway
#开机启动
systemctl enable zabbix-java-gateway
zabbix-java-gateway默认工作在10052端口
zabbix-server默认工作在10051端口,zabbix-agent默认工作在10050端口
配置zabbix_java_gateway.conf和zabbix_server.conf
2个文件都在/etc/zabbix下
重点:Java-gateway配置文件的START_POLLERS参数 >= zabbix_server配置文件的StartJavaPollers参数,建议一样,都设为5。
----------------------------------------------------------------------------
配置zabbix_java_gateway.cnf
# This is a configuration file for Zabbix Java Gateway.
# It is sourced by startup.sh and shutdown.sh scripts.
### Option: zabbix.listenIP
# IP address to listen on.
#
# Mandatory: no
# Default:
LISTEN_IP="0.0.0.0"(本机ip地址,如果和server安装在相同的位置可以不修改)
### Option: zabbix.listenPort
# Port to listen on.
#
# Mandatory: no
# Range: 1024-32767
# Default:
LISTEN_PORT=10052(端口可以修改为其他,在server段需要相同的配置)
### Option: zabbix.pidFile
# Name of PID file.
# If omitted, Zabbix Java Gateway is started as a console application.
#
# Mandatory: no
# Default:
# PID_FILE=
PID_FILE="/var/run/zabbix/zabbix_java.pid"
### Option: zabbix.startPollers
# Number of worker threads to start.
#
# Mandatory: no
# Range: 1-1000
# Default:
START_POLLERS=5(设置启动多个线程,这里和server段相同)
### Option: zabbix.timeout
# How long to wait for network operations.
#
# Mandatory: no
# Range: 1-30
# Default:
# TIMEOUT=3
TIMEOUT=3(超时时间)
---------------------------------------------------------------
配置zabbix_server.conf:
让zabbix-server服务能连接到zabbix-java-gateway服务
### Option: JavaGateway(找到这里配置以下三个参数)
# IP address (or hostname) of Zabbix Java gateway.
# Only required if Java pollers are started.
# Mandatory: no
# Default:
JavaGateway=192.168.199.63 #如果是本机安装直接使用127.0.0.1
### Option: JavaGatewayPort
# Port that Zabbix Java gateway listens on.
# Mandatory: no
# Range: 1024-32767
# Default:
JavaGatewayPort=10052 #端口号和javagateway要对应
### Option: StartJavaPollers
# Number of pre-forked instances of Java pollers.#
# Mandatory: no
# Range: 0-1000
# Default:
StartJavaPollers=5 #线程数和客户端配置对应 不能少于客户端数目
-----------------------------------------------------------------------------
#StartJavaPollers<=START_POLLERS
#重启zabbix-server和zabbix-java-gateway服务
systemctl restart zabbix-server
systemctl restart zabbix-java-gateway
#配置linux系统客户端
#本例tomcat安装在linux系统上,稍后再写windows
#配置上tomcat
#添加tomact中JMX的参数
#打开tomcat/bin/catalina.sh文件,在#!/bin/sh下面添加如下
-------------------------------
CATALINA_OPTS="$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=10.1.2.135"
---------------------------------------------------
#(CATALINA_OPTS="$CATALINA_OPTS
#-Dfile.encoding=utf-8
#-Dcom.sun.management.jmxremote #开启远程
#-Dcom.sun.management.jmxremote.authenticate=false #免密认证
# -Dcom.sun.management.jmxremote.port=12345 #这里不需要这行,一会儿说明原因
#-Dcom.sun.management.jmxremote.ssl=false
#-Djava.rmi.server.hostname=192.168.66.22" #要监控的tomcat主机ip
#注意添加的位置在#!/bin/sh下面。
#注意-Djava.rmi.server.hostname=192.168.2.32要加了,hostname填本机的ip地址,除非是127.0.0.1
#查看12345端口监听情况:netstat -antlp|grep 12345
#测试
[root@cc-kbs01 bin]# lsof -i:12345
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 12082 root 20u IPv6 6640905 0t0 TCP *:italk (LISTEN)
[root@cc-kbs01 bin]# netstat -antlp|grep 12345
tcp6 0 0 :::12345 :::* LISTEN 12082/java
[root@cc-kbs01 bin]#
#添加catalina-jmx-remote.jar
在tomcat/lib下执行:wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.5.37/bin/extras/catalina-jmx-remote.jar
#要找到对应tomcat版本的catalina-jmx-remote.jar。访问tomcat各个版本网站,从上面一直找下去。catalina-jmx-remote.jar文件在tomcat版本的/bin/extras/目录下,只要替换wget后面url即可。
#重启tomcat
#执行bin目录下shell脚本
./shutdown.sh
./startup.sh