Zabbix Proxy distributed monitoring

Source: Internet
Author: User

Zabbix Proxy distributed monitoring

Introduction:

Zabbix is a distributed monitoring system that can run in a central point and multiple nodes. Using proxy can reduce the pressure on Zabbix Server, which also brings about costs ~

Applicability: a network monitoring system across data centers and regions can monitor regions with unreliable network connections, simplify maintenance of distributed monitoring, and share the pressure on Zabbix Server.

Example:

The company has one or more projects, and a large number of servers in different regions need to be monitored. A Zabbix Server cannot be set up in one region, which means it is inconvenient to manage and waste resources, if a Zabbix Server is used to monitor all machines, the Server must have good performance (a large number of machines, which is basically impossible ). In this case, you can use the Proxy to set up Zabbix Server inside the company or somewhere, and put a Proxy in each region to collect the Agent data of this region, and then send it to Zabbix Server. Is this convenient?

1. Zabbix Proxy active mode (it can be used when the Proxy does not have a public IP but can access the public network)

Zabbix Server <-Zabbix Proxy-> Zabbix Agent

# This is the active Proxy mode, so the Proxy requests the Zabbix Server. Because Zabbix Agent uses the passive mode, Zabbix Proxy also requests the Zabbix Agent.

Zabbix Server: 192.168.214.40
Zabbix Proxy: 192.168.214.10
Zabbix Agent: 192.168.214.20

1. Install Zabbix Server (Portal :)

2. Install Zabbix Proxy

# Install MySQL (Portal :)

: Http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz

Shell> useradd-r-s/sbin/nologin zabbix # create Zabbix run user

Shell> wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz

Shell> tar zxf zabbix-2.4.5.tar.gz
Shell> cd zabbix-2.4.5
Shell>. /configure -- prefix =/usr/local/zabbix -- enable-agent -- enable-proxy -- with-mysql # -- enable-agent is not required (if you do not want to monitor Proxy)
Shell> make install

Shell> cp/usr/local/src/zabbix-2.4.5/misc/init. d/Fedora/core/zabbix_agentd/etc/init. d/# copy Agent Startup Script
Shell> sed-I's # BASEDIR =/usr/local/zabbix # '/etc/init. d/zabbix_agentd # modify Zabbix installation path

Shell> mysql

Mysql> create database proxydb character set utf8; # create a database
Mysql> grant all on proxydb. * to proxy @ localhost identified by 'proxypass'; # create an authorized user
Mysql> flush privileges; # refresh the authorization table ~
Mysql> use proxydb;
Mysql> source/usr/local/src/zabbix-2.4.5/database/mysql/schema. SQL # import data, only this one can be imported

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_proxy.conf # The modified configuration file is as follows (of course there are some performance parameters, not listed here)

ProxyMode = 0 #0 indicates that the Proxy is in active mode. That is, the Proxy actively requests the Zabbix Server to obtain the monitoring metrics. 1 indicates that the Proxy is in passive mode.
Server = 192.168.214.40 # Zabbix Server address. When the Proxy is in passive mode, you do not need to set this option (think about it as well)
ServerPort = 10051 # The listening port of Zabbix Server, which takes effect only when Proxy is active.
Hostname = my_proxy # this is very important. It is as important as the Hostname of the Agent. It will be used later.
LogFile =/tmp/zabbix_proxy.log # location of the Proxy Log File
DBHost = localhost # Database connected
DBName = proxydb # Database Name
DBUser = proxy # connect to the user
DBPassword = proxypass # User Password
ConfigFrequency = 60 # interval between Proxy requests to Zabbix Server monitoring metrics, in seconds
DataSenderFrequency = 60 # Proxy sends monitoring data interval to Zabbix Server, in seconds

Shell>/usr/local/zabbix/sbin/zabbix_proxy # Start zabbix_proxy
Shell> echo "/usr/local/zabbix/sbin/zabbix_proxy">/etc/rc. local # Add boot start

Shell> netstat-lnpt | grep zabbix_proxy
Tcp 0 0 0.0.0.0: 10051 0.0.0.0: * LISTEN 16073/zabbix_proxy

 

# Zabbix_proxy is all configured

 

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_agentd.conf # This is the configuration file after the Agent on Zabbix Proxy is modified.
LogFile =/tmp/zabbix_agentd.log # location of the Agent log file
Server = 192.168.214.10 # Zabbix Proxy host address
Hostname = proxy_agent # It is also very important to identify your own and will be used later

Shell> service zabbix_agentd start # start the Agent

Shell> netstat-lnpt | grep zabbix_agentd
Tcp 0 0 0.0.0.0: 10050 0.0.0.0: * LISTEN 16148/zabbix_agentd

Shell> chkconfig -- add zabbix_agentd # add to startup
Shell> chkconfig -- level 35 zabbix_agentd on

 

# The above section is about Agent Configuration

3. Install Zabbix Agent

 

Shell> useradd-r-s/sbin/nologin zabbix # create Zabbix run user

Shell> wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz

Shell> tar zxf zabbix-2.4.5.tar.gz
Shell> cd zabbix-2.4.5
Shell>./configure -- prefix =/usr/local/zabbix -- enable-agent # Install the Agent
Shell> make install

Shell> cp/usr/local/src/zabbix-2.4.5/misc/init. d/fedora/core/zabbix_agentd/etc/init. d/# copy Agent Startup Script
Shell> sed-I's # BASEDIR =/usr/local/zabbix # '/etc/init. d/zabbix_agentd # modify Zabbix installation path

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_agentd.conf # This is the configuration file after the Agent on Zabbix Proxy is modified.
LogFile =/tmp/zabbix_agentd.log # location of the Agent log file
Server = 192.168.214.10 # Zabbix Proxy host address
Hostname = nodeslave Agent # It is also very important to identify your own and will be used later

Shell> service zabbix_agentd start # start the Agent

Shell> netstat-lnpt | grep zabbix_agentd
Tcp 0 0 0.0.0.0: 10050 0.0.0.0: * LISTEN 16148/zabbix_agentd

Shell> chkconfig -- add zabbix_agentd # add to startup
Shell> chkconfig -- level 35 zabbix_agentd on

Shell> iptables-a input-p tcp -- dport 10050-j ACCEPT # because the Agent uses the passive mode, you must enable TCP 10050 to wait for the Server or Proxy connection.
Shell> service iptables save

 

# The above sections are all done for Zabbix Proxy and Zabbix Agent, and the rest is completed on the Web interface of Zabbix Server!

> Administration-> Proxies-> Create proxy

Proxy name: my_proxy # the Hostname in the Zabbix Proxy configuration file must be written
Proxy mode: Active # select Active mode here, because Zabbix Proxy's configuration file defines 0, Active mode

> Update # You can directly Update the host. If the host has been added in advance, you can add the corresponding host to the Proxy hosts! They are all the same

> Configuration-> Hosts-> Create host

Host name: node1_agent # the Hostname in the Zabbix Agent configuration file must be written
Visible name: # It can be written or not written. It is a display name.
Groups In groups: # the group to which the host is placed. You can use the New group below to customize a group.
New group: Proxy # custom group
Agent interfaces: 192.168.214.20 # Agent Host IP address, which host to monitor and which host to write
Monitored by proxy: my_proxy # select the proxy created earlier

> Templates # On the second tab, select a template to link to the host.
> Update

# In this way, a host is added and the my_proxy proxy mode is used.

# Now you can go through the Proxy Agent status! Everything is normal

Ii. Passive Zabbix Proxy mode (it can be used when Zabbix Server does not have a public IP address but can access the public network)

Zabbix Server-> Zabbix Proxy-> Zabbix Agent

# This is the Proxy passive mode. Therefore, the Zabbix Server actively sends monitoring metrics to the Proxy, and the Proxy passively receives data because the Zabbix Agent uses the passive mode, therefore, Zabbix Proxy requests the Zabbix Agent.

Zabbix Server: 192.168.214.40
Zabbix Proxy: 192.168.214.10
Zabbix Agent: 192.168.214.20

# The environment is still the environment. Here are some changes and notes.

1. configuration file of Zabbix Proxy

 

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_proxy.conf
ProxyMode = 1 #1 indicates the passive mode, that is, the Proxy passively receives metrics from the Zabbix Server.
Hostname = my_proxy
LogFile =/tmp/zabbix_proxy.log
DBHost = localhost
DBName = proxydb
DBUser = proxy
DBPassword = proxypass

 

# Because it is in passive mode, you do not need to know the IP address of Zabbix Server

2. Zabbix Agent also uses the original configuration file.

3. When adding a Proxy to the Web interface of Zabbix Server, note that

> Administration-> Proxies-> Create proxy

Proxy name: my_proxy # the Hostname in the Zabbix Proxy configuration file must be written
Proxy mode: Passive # Passive mode is selected here, because Zabbix Proxy's configuration file defines 1, Passive mode

# The rest can remain unchanged, and the Proxy's passive mode Proxy will be completed

# The active and passive modes of the Proxy are irrelevant to the Agent to be Proxy. It is not important for the Zabbix Server to directly access the Agent. As long as the Proxy can access the Agent, the Server can access the Proxy!

3. Simulate another situation

Zabbix Server <-> Route <-> Zabbix Proxy-> Zabbix Agent

# In this case, the Proxy and Agent are in the same network segment and have only one IP address. The Zabbix Server is monitored in another region.
# <-> Indicates different Proxy modes, which can be ignored.

Example: The Zabbix Server is installed in the company. The Proxy and Agent are in a local data center in another province and are in the LAN. they connect to the Internet through routing.

Zabbix Server: 192.168.214.40
Zabbix Proxy: 172.16.0.10
Zabbix Agent: 172.16.0.20

Route: 192.168.214.30 (external)
: 172.16.0.50 (internal)

1. Suppose I have mapped Zabbix Server to the company's public IP address (this is a good implementation, right?). My current Zabbix Server IP address is 192.168.214.40

2. simulate a route

 

Shell> ifconfig eth0: 0 172.16.0.50/16 up # Add a simulated Intranet address

Shell> vim/etc/sysctl. conf # enable route forwarding

Net. ipv4.ip _ forward = 1

Shell> sysctl-p # make the change take effect

Shell> iptables-t nat-a prerouting-d 192.168.214.30-j DNAT -- to 172.16.0.10
Shell> iptables-t nat-a postrouting-d 172.16.0.10-j SNAT -- to 172.16.0.50

# Add two firewall rules

# Test: You can use a stupid but effective method to test. The Proxy has an httpd, then use curl or a browser to access 214.30 to see if httpd on 0.10 can be accessed; or use nmap to scan the port.

3. Zabbix Proxy configuration file (the passive mode is used here. You can also take the initiative)

 

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_proxy.conf
ProxyMode = 1 #1 indicates the passive mode, that is, the Proxy passively receives metrics from the Zabbix Server.
Hostname = my_proxy
LogFile =/tmp/zabbix_proxy.log
DBHost = localhost
DBName = proxydb
DBUser = proxy
DBPassword = proxypass

4. Zabbix Agent configuration file

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_agentd.conf
LogFile =/tmp/zabbix_agentd.log
Server = 172.16.0.10 # Zabbix Proxy host IP
Hostname = nodeslave agent

5. Web interface configuration in Zabbix Server

About Adding hosts:

Agent interfaces: 172.16.0.20 # the IP address and port of the host to be monitored are actually the same as those added normally.

About Proxy:

Proxy mode: Passive # Passive mode
Interface: 192.168.214.30 # Route's public IP address, because the request for this address has been transferred to the actual Proxy host

# OK. The LAN environment on both sides with routes also uses Proxy to solve the monitoring problem!

4. No route, but the Proxy has two IP addresses. Zabbix Server cannot directly access the Agent.

Zabbix Server <-> Zabbix Proxy-> Zabbix Agent

# Let's take a look at this situation: the Proxy is in the same LAN as the Agent, and the Proxy itself has a public IP that can communicate with the Zabbix Server, but the Server cannot directly access the Agent

Zabbix Server: 192.168.214.40
Zabbix Proxy: 192.168.214.10 (external)
172.16.0.10 (internal)
Zabbix Agent: 172.16.0.20

1. Proxy host settings

 

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_proxy.conf)

ProxyMode = 0 #0 indicates that the Proxy is in active mode. That is, the Proxy actively requests the Zabbix Server to obtain the monitoring metrics.
Server = 192.168.214.40 # Zabbix Server address. When the Proxy is in passive mode, you do not need to set this option (think about it as well)
ServerPort = 10051 # The listening port of Zabbix Server, which takes effect only when Proxy is active.
Hostname = my_proxy # this is very important. It is as important as the Hostname of the Agent. It will be used later.
LogFile =/tmp/zabbix_proxy.log # location of the Proxy Log File
DBHost = localhost # Database connected
DBName = proxydb # Database Name
DBUser = proxy # connect to the user
DBPassword = proxypass # User Password
ConfigFrequency = 60 # interval between Proxy requests to Zabbix Server monitoring metrics, in seconds
DataSenderFrequency = 60 # Proxy sends monitoring data interval to Zabbix Server, in seconds

Shell> route add-net 172.16.0.0/16 gw 172.16.0.10 # add a route. Otherwise, monitoring will fail (note !)

2. Zabbix Agent configuration file

Shell> grep-vP '^ $ | #'/usr/local/zabbix/etc/zabbix_agentd.conf
LogFile =/tmp/zabbix_agentd.log
Server = 172.16.0.10 # Zabbix Proxy host IP address (intranet IP address, because the Agent cannot access the Internet)
Hostname = nodeslave agent

3. Web interface configuration in Zabbix Server

About Adding hosts:

Agent interfaces: 172.16.0.20 # the IP address and port of the host to be monitored are actually the same as those added normally.

About Proxy:

Proxy mode: Active # Active mode, defined in the configuration file (if the passive mode is used, the IP address written below is the public IP address of the Proxy)

Some Zabbix Tutorials:

Compile and install Zabbix2.4.5 source code in Ubuntu 14.04

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy Zabbix in CentOS 6.3

Zabbix distributed monitoring system practice

Under CentOS 6.3, Zabbix monitors apache server-status

Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3

Install Zabbix 2.0.6 in 64-bit CentOS 6.2

ZABBIX details: click here
ZABBIX: click here

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.