Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of building Zabbix monitoring system

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

In the process of enterprise network operation and maintenance, administrators must pay attention to the operation of each server and network at any time in order to find problems in time and reduce the occurrence of failures as much as possible. When there are a large number of devices and servers in the network, in order to obtain all kinds of monitoring information more conveniently and quickly, we usually rely on some centralized monitoring software.

Blog outline:

I. Overview, working principle and important components of Zabbix

II. Zabbix installation

Configure Zabbix monitoring system to monitor network equipment

If you want to know the running status of the server in real time and solve problems in time, it is a good way to use monitoring software. At present, there must be a monitoring system where there is a server. There are many existing monitoring software, but Zabbix can flexibly monitor server resources, and integrates the advantages of both Cacti and Nagio, and the function is more powerful, so it is widely used in the market!

1. Overview, working principle and important components of Zabbix; (1) Overview of Zabbix

Zabbix is an enterprise-class open source monitoring suite based on Web interface, which provides distributed system monitoring and network monitoring functions. It has the functions of host performance monitoring, network equipment performance monitoring, database performance monitoring, a variety of alarm methods, detailed reports, chart drawing and other functions. The monitoring object can be Linux or Windows server, router, switch and other network equipment. Through SNMP (simple Network Management Protocol), Zabbix, Agent, PING, port monitoring and other methods to provide remote network server monitoring, data collection and other functions, and provide notification mechanism to enable system administrators to quickly locate and solve various problems in the system. At present, the latest version of Zabbix is Zabbix 3.4. The official website is http://www.zabbix.com.

Zabbix is free. Zabbix follows GPL (General Public license) version 2, which means that its source code can be freely distributed. The commercial version of Zabbix is supported by Zabbix. Many organizations of different sizes in the world are lazy to use Zabbix as one of their main monitoring platforms. Especially now many Internet companies are using it.

Zabbix is a highly integrated network monitoring solution, as shown in the figure:

(2) important components of Zabbix

Zabbix is mainly composed of the following important components, and the specific functions are as follows:

Zabbix Server: the core component responsible for receiving Agent report information, which organizes all configuration, data statistics and data operations; Database strongage: responsible for storing all configuration information and collected data; Web interface: it is the GUI interface of zabbix, usually running on the same host as Zabbix Server Proxy: it is an optional component and is often used in distributed monitoring environment. Proxy Server collects part of the data and then forwards it to Server, which can reduce the pressure on Server. Agent: deployed on the monitored host (client), is responsible for collecting data from the monitored host, such as CPU, memory, database, etc., and then sending it to the server or proxy. (3) Zabbix process

By default, Zabbix contains five programs, and another one is optional and needs to be installed separately.

The characteristics and functions of each program are as follows:

Zabbix_agentd: client daemon, which is used to collect data from the monitored side, such as CPU load, memory, hard disk usage, etc. The zabbix_get:zabbix tool is a separate command. Zabbix_get is a command to get remote client information on the server or proxy side. It is mainly used for troubleshooting. For example, when the client's memory data is not available on the server side, we can use zabbix_get to obtain the client's content for troubleshooting; zabbix_sender: used to send data to server or Proxy, usually used for time-consuming checks. Many checks are time-consuming, causing zabbix to time out. So after the script is executed, we can use sender to actively submit the data; the zabbix_server:zabbix server-side daemon. Zabbix_agentd 、 zabbix_get 、 zabbix_sender 、 zabbix_proxy 、

Zabbix_java_gateway 's data is ultimately submitted to server. Not all data is actively submitted to zabbix_server, but also passively submitted, and server takes the initiative to obtain data; zabbix_proxy:zabbix agent daemon. The function is similar to server, except that it is only a transit station that needs to actively (or passively) submit the collected data to the server; zabbix_java_gateway: a feature introduced after zabbix2.0. As the name implies: Java gateway, similar to agentd, but currently only used in Java, need to pay special attention to, it can only take the initiative to obtain data, not passive access to data. Its data will eventually be submitted to server or proxy. (4) Zabbix monitoring architecture

In the actual production environment, Zabbix is divided into three architectures according to external factors such as network environment and monitoring scale, as shown in the figure:

1) server-client architecture (direct connection)

Server-client architecture is the simplest architecture of Zabbix. The monitoring computer and the monitored computer can exchange data directly between zabbix server and zabbix agentd without any agent. It is suitable for the monitoring environment where the network is simple and there are few devices.

2) master-node-client architecture (node architecture)

Master-node-client architecture is the most complex monitoring architecture of Zabbix, which is suitable for large-scale environments with more devices and across networks and computer rooms. Each node is also a server. You can connect to proxy or client directly under node. Node has its own configuration file and database. What it needs to do is to synchronize the configuration information with the monitoring data item master. When master fails or is damaged, node can guarantee the integrity of the architecture.

3) server-proxy-client architecture (proxy architecture)

Proxy is a bridge between server and client, proxy itself does not have a front end, and it does not store data itself, but temporarily stores the data sent by agentd, and then submits it to server. This architecture is often compared with the master-node-client architecture, and is generally suitable for the monitoring of medium-sized network architecture across computer rooms and networks.

II. Zabbix installation

Zabbix provides two installation methods: YUM installation and compilation installation. It should be noted that since Zabbix packages and related lazy packages are not available in the official Centos Yum source, if you want to install Zabbix with YUM, you need to implement it through the Zabbix official source or a third-party YUM source.

Zabbix server needs LAMP environment or LNMP environment. The following experimental deployment environment uses the LAMP environment installed by YUM as an example to introduce the deployment method of Zabbix monitoring server in detail.

(1) install MariaDB

Why install MariaDB instead of MySQL?

Because the default database provided on the Centos 7 system CD is not MySQL but MariaDB, MariaDB is used in the LAMP architecture to play the role of "M", and the rest of the components remain the original Apache and PHP. MariaDB is a branch of the source code of the MySQL database and is compatible with MySQL in most aspects!

[root@localhost ~] # yum-y install mariadb-server mariadb// install MariaDB database and MariaDB client tools [root@localhost ~] # systemctl start mariadb// launch MariaDB database [root@localhost ~] # mysqladmin-u root password "password123" / / set password for MariaDB database administrator [root@localhost ~] # mysql-u root-ppassword123// login MariaDB database Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 3Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] > / / login succeeded (2) install Zabbix

Because a lot of lazy packages will be installed when installing Zabbix, including httpd and PHP related lazy packages, so install Zabbix directly! There is no need to install httpd and PHP separately. Using YUM to install Zabbix, you can use the Zabbix official source or the YUM source provided by a third party. Take the YUM provided by the third party as an example!

Link to the network disk of the software package required to install Zabbix: https://pan.baidu.com/s/1mnOHhY7EVmmMnONFetMUUg

Extraction code: b2sd

It is recommended to decompress the Windows system and upload the required software packages for YUM to the Linux server.

[root@localhost ~] # mount / dev/cdrom / mnt [root@localhost ~] # cp / mnt/* / a [root@localhost ~] # cd / a [root@localhost a] # createrepo. / / because it only comes with a software package and does not have the dependency files it needs to use, so you need to generate it manually! [root@localhost ~] # yum-y install zabbix-server-mysql zabbix-web-mysql zabbix-agent// installs Zabbix and its required services (direct YUM installation if official sources are used)! / / the zabbix-agent service is installed by the monitoring end.

Because you need a database to install Zabbix Web, you need to manually create a database named Zabbix in MariaDB and authorize it to zabbix users to increase the security of the database.

[root@localhost] # mysql-u root-ppassword123Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 4Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.MariaDB [(none)] > create database zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.01 sec) MariaDB [(none)] > grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by' password@456';Query OK, 0 rows affected (0.00 sec) / / Log in to the database to create the database and grant permissions

Import database SQL script files

[root@localhost ~] # zcat / usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz | mysql- u zabbix- ppassword@456 zabbix1) check its configuration file

Write a Zabbix server configuration file that specifies the name, user, and password of the database.

[root@localhost] # vim / etc/zabbix/zabbix_server.conf... / / omit part of the content DBHost=localhost / / remove comments DBName=zabbix / / unchanged DBUser=zabbix / / unchanged DBPassword=password@456 / / remove comments

To edit the configuration file for Zabbix agent, you must specify the IP address of zabbix server, which must be configured on each host on which agent is installed.

[root@localhost] # vim / etc/zabbix/zabbix_agentd.conf... / / omit part of the content Server=127.0.0.1 / / the client passively waits for the specified server to query the data ServerActive=127.0.0.1 / / the client actively submits data to the specified server Hostname=linux-server001 / / modify / / because the local machine is zabbix server, so the specified address is the local machine! 2) install Zabbix Web interface

Edit the front-end configuration file of the Apache server for Zabbix, and set the time zone consistent with the current system time zone! The contents are as follows:

[root@localhost] # vim / etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Shanghai// remove the comments and modify them! 3) restart all services [root@localhost ~] # systemctl stop firewalld [root@localhost ~] # setenforce 0bat / it is recommended to turn off the firewall and SELinux [root@localhost ~] # systemctl restart zabbix-server.service [root@localhost ~] # systemctl restart zabbix-agent.service [root@localhost ~] # systemctl restart httpd4) client access

Can be accessed locally or on the client side, both!

4) Zabbix user Management

To enhance security, you need to change the initial password of Admin, the default user of the Zabbix server, as follows:

5) modify Zabbix Chinese garbled code

After installing Zabbix, Chinese garbled may occur when the display language is Chinese. The problem is mainly caused by fonts. If you need to solve the problem, you need to download the appropriate font and upload it to the Zabbix server.

Download the standard Chinese font and upload it to the document root of the Zabbix server; the Chinese font (simkai.ttf) is also in the compressed package connected to the network disk just now. The specific operations are as follows:

[root@localhost ~] # cp simkai.ttf / usr/share/zabbix/fonts/ [root@localhost ~] # ls / usr/share/zabbix/fonts/graphfont.ttf simkai.ttf

Execute the following command to modify the font file specified by the PHP interface, change the original grapfont to simkai, and then refresh the interface to display Chinese normally.

[root@localhost] # vim / usr/share/zabbix/include/defines.inc.php... / / omit some content define ('ZBX_GRAPH_FONT_NAME',' simkai')

The zabbix server has been built!

Configure Zabbix monitoring system to monitor network equipment

In the enterprise network environment, Zabbix is used as the monitoring server, and the monitoring objects are various servers and network devices in the network. The server has Linux server and Windows server, and the switch is simulated by GNS3 simulator. Three network cards are bridged to connect the Zabbix server, Linux server and Windows server respectively. The specific experimental diagram is as follows:

Case implementation steps:

(1) Zabbix monitors network equipment

Network equipment generally supports SNMP protocol for monitoring, so first configure the IP address on the switch, and turn on SNMP, mainly to set the value of the community. This case uses a GNS3 simulator and a router instead of the switch. The specific operations are as follows:

R1 (config) # int r f0Let0-15R1 (config-if-range) # no shR1 (config) # int vlan 1R1 (config-if) # ip add 192.168.1.100 255.255.255.0R1 (config-if) # no sh// set the IP address R1 (config) # no ip routing// turn off routing R1 (config) # snmp-server community centos ro// set the read-only Community R1 (config) # snmp-server enable queried by the server Traps// allows sending trap messages R1 (config) # snmp-server host 192.168.1.1 centos// sets the community that sends trap messages

Add a network device to the Zabbix server as follows:

The name of the switch will be updated later!

Switch detection completed!

(2) Monitoring Linux server

If you want to monitor the Linux server, you can use the agent method, that is, install Zabbix's agent on the Linux server. The agent package is also in the zabbix package and modifies its configuration file.

[root@localhost ~] # systemctl stop firewalld [root@localhost ~] # setenforce 0 / turn off the firewall and SELinux [root@localhost ~] # rpm-ivh zabbix-agent-3.2.6-1.el7.x86_64.rpm / / install the agent package [root@localhost ~] # vim / etc/zabbix/zabbix_agentd.conf / / write the configuration file for the agentd server. / / omit part of the content Server=192.168.1.1// is used for the client to passively wait for the specified server to query data ServerActive=192.168.1.1// is used for the client to actively submit data to the specified server Hostname=linux-server001// can be customized, but it must be consistent with the configuration on Zabbix Web, otherwise Zabbix active monitoring will not work. [root@localhost ~] # systemctl start zabbix-agent.service / / start the agent service [root@localhost ~] # netstat-anpt | grep 10050tcp 00 0.0.0.0 agent 10050 0.0.0.0 netstat * LISTEN 43876/zabbix_agentd tcp6 00: 10050:: * LISTEN 43876/zabbix_agentd / / agent service default port is 10050

Add a Linux host on the Zabbix server as follows:

(3) Monitoring Windows server

The 32-bit operating system of the Windows server chooses 32-bit software packages; 64-bit operating systems choose 64-bit software packages, all of which are available in Zabbix packages.

Create a new folder in disk C and name it zabbix, move the required software and configuration files into it, and modify the configuration file as follows:

Server=192.168.1.1

ServerActive=192.168.1.1

Hostname=windows-server001

After the modification is completed, it is recommended to turn off the firewall to avoid errors!

Next, do the following on the command line:

C:\ Users\ Administrator > cd\ zabbixC:\ zabbix > zabbix_agentd.exe-c zabbix_agentd.win.conf-izabbix_agentd.exe [1368]: service [Zabbix Agent] installed successfullyzabbix_agentd.exe [1368]: event source [Zabbix Agent] installed successfully// installation agentC:\ zabbix > zabbix_agentd.exe-c zabbix_agentd.win.conf-szabbix_agentd.exe [1504]: service [Zabbix Agent] started successfully// specifies agent profile launch agent common options are: "- c" specify configuration file; "- I" install "- s" starts; "- x" stops; "- d" uninstalls!

Add a Windows host on the Zabbix server as follows:

(4) Zabbix custom monitoring items

The default template that comes with Zabbix contains many monitoring items, which can also be customized according to business requirements.

Taking monitoring httpd process as an example, this paper introduces how to customize monitoring items in Zabbix.

The following actions are performed on the client side with the following commands:

[root@localhost ~] # vim check_httpd.sh// writes the script manually, as follows: #! / bin/bashA= `ps-ef | grep httpd | grep-v grep`if [- n "$A"] then echo '1'else echo' 0F [root @ localhost ~] # vim / etc/zabbix/zabbix_agentd.conf// modifies the configuration file of the agent service Modify the following UnsafeUserParameters=1 / / remove the comments and change it to 1 [root@localhost ~] # vim / etc/zabbix/zabbix_agentd.d/userparameter_httpd.conf// to create the Userparameter_httpd.conf file UserParameter=check_httpd,sh / root/check_httpd.sh// format as Userparameter=

Log in to the Zabbix server

About the configuration of Zabbix to accept so much first, there are new problems in the future, it will be updated in real time!

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report