Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

环境

server1 172.25.75.1 zabbix-server、zabbix-agen、mysql
server2 172.25.75.2 zabbix-agent、http
server3 172.25.75.3 zabbix-agent、nginx

一、配置Zabbix监控Java

1、server1配置tomcat服务

[[email protected] ~]# ls apache-tomcat-8.5.24.tar.gz zabbix-agent-4.0.5-1.el7.x86_64.rpm 
apache-tomcat-8.5.24.tar.gz  zabbix-agent-4.0.5-1.el7.x86_64.rpm
[[email protected] ~]# rpm -ivh jdk-8u121-linux-x64.rpm 
[[email protected] ~]# tar zxf apache-tomcat-8.5.24.tar.gz -C /usr/local/
[[email protected] ~]# cd /usr/local/
[[email protected] local]# ln -s apache-tomcat-8.5.24 tomcat

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

[[email protected] local]# cd tomcat/bin/
[[email protected] bin]# vim catalina.sh
110 CATALINA_OPTS='-Dcom.sun.management.jmxremote
111   -Dcom.sun.management.jmxremote.prot=8888
112   -Dcom.sun.management.jmxremote.ssl=false
113   -Dcom.sun.management.jmxremote.authenticate=false'
[[email protected] bin]# ./startup.sh
[[email protected] bin]# netstat -tnlp

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

2、在server1上安装java-gateway

[[email protected] ~]# yum install zabbix-java-gateway-4.0.5-1.el7.x86_64.rpm -y
[[email protected] ~]# systemctl start zabbix-java-gateway
[[email protected] ~]# netstat -tnlp | grep 10052
tcp6       0      0 :::10052                :::*                    LISTEN      31039/java  

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

3、更改server配置文件

[[email protected] bin]# vim /etc/zabbix/zabbix_server.conf 
288 JavaGateway=172.25.75.1
296 JavaGatewayPort=10052
304 StartJavaPollers=5
[[email protected] bin]# systemctl restart zabbix-server

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

4、web界面配置

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
添加JMX接口
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
添加模板。
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
可以看到server1的JMX监控打开了。

二、Zabbix-agent被动变为主动-搭建Proxy代理

环境

server1 172.25.75.1 zabbix-server
server2 172.25.75.2 zabbix-agent
server3 172.25.75.3 proxy

1、web端搭配agent代理程序

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
创建代理
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

2、在server3配置proxy代理

[[email protected] ~]# ls zabbix-proxy-mysql-4.0.5-1.el7.x86_64.rpm fping-3.10-1.el7.x86_64.rpm 
fping-3.10-1.el7.x86_64.rpm  zabbix-proxy-mysql-4.0.5-1.el7.x86_64.rpm
[[email protected] ~]# yum install fping-3.10-1.el7.x86_64.rpm zabbix-proxy-mysql-4.0.5-1.el7.x86_64.rpm -y

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
下载mysql:

[[email protected] ~]# yum install -y mariadb-server
[[email protected] ~]# systemctl start mariadb

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
初始化mairadb

[[email protected] mysql]# mysql_secure_installation

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

3、数据库操作

MariaDB [(none)]> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix_proxy.* to [email protected] identified by 'redhat';

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

[[email protected] ~]# cd -
-bash: cd: OLDPWD not set
[[email protected] ~]# cd /usr/share/doc/zabbix-proxy-mysql-4.0.5/
[[email protected] zabbix-proxy-mysql-4.0.5]# ls
AUTHORS  ChangeLog  COPYING  NEWS  README  schema.sql.gz
[[email protected] zabbix-proxy-mysql-4.0.5]# zcat schema.sql.gz | mysql -p zabbix_proxy
Enter password: 

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

4、更改zabbix—proxy配置文件

[[email protected] zabbix-proxy-mysql-4.0.5]# vim /etc/zabbix/zabbix_proxy.conf
 30 Server=172.25.75.1
 39 ServerPort=10051
  49 Hostname=proxy
  196 DBPassword=redhat
  329 JavaGateway=172.25.75.1
  337 JavaGatewayPort=10052
  345 StartJavaPollers=5
  [[email protected] ~]# systemctl start zabbix-proxy

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

5、查看zabbix-proxy日志及server1的zabbix-server日志

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

6、更改server2的zabbix-agent的配置文件

[[email protected] bin]# vim /etc/zabbix/zabbix_agentd.conf
 98 Server=172.25.75.3
139 ServerActive=172.25.75.3
[[email protected] bin]# systemctl restart zabbix-agent

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理

7、web端配置

Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
配置server2的proxy的代理
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理
server3的zabbix-proxy服务日志:
Zabbix监控Java、Zabbix-agent被动变为主动-搭建Proxy代理