Developer Linux: CentOS7 installation configuration IT equipment monitoring system Zabbix

Source: Internet
Author: User
Tags ldap memcached snmp sqlite database openldap

1. Preface

In the previous article on how to install memcached and Redis, this article mainly describes how to install enterprise-level IT equipment monitoring system Zabbix. I have worked in the Informatization Department of a large group of companies, the company has offices in multiple cities and multiple districts in a city, where not only will the development of software systems, but also a large number of software systems, operating systems and IT equipment monitoring to ensure that IT infrastructure can be 7x24 small work. Before the implementation of the system, often received the phone is told that the network is interrupted or an application is not available, each time after receiving the call to eliminate the false alarm, and then analyze where the problem is, and finally find a solution. Every time the cycle of things is very long, but also very troublesome, so I look for similar software on the Internet, and finally in smokeping, cacti, Nagios, Zabbix, ntop and many other software selected Zabbix. Zabbix's official website is: https://www.zabbix.com, due to the development of many years, so on the official website has a large number of documents and monitoring templates.


Zabbix is an enterprise-class open source solution that provides distributed system monitoring and network monitoring capabilities based on a web interface. Zabbix can monitor various network parameters, ensure the safe operation of the server system, and provide a soft notification mechanism for the system administrator to quickly locate/resolve various problems. Zabbix consists of 2 parts, Zabbix server and optional Components Zabbix agent. Zabbix server can provide monitoring of remote server/network status, data collection and other functions through Snmp,zabbix agent,ping, port monitoring, etc., which can run on Linux, Solaris, HP-UX, AIX, free BSD, Open BSD, OS X and other platforms. Zabbix server must be installed on a Linux system, but the Zabbix agent has a version that adapts to various operating systems.


Of course, if it is a simple application of a person or group, you can consider developing some gadgets to implement, such as Windows can use tools such as PerformanceCounter (there are similar tools on Linux) to achieve some of the functions, I have tried before, Have seen others have done similar work, but after all, the application surface is relatively narrow, want to fully monitor, or use enterprise-level IT equipment and system open source monitoring tool is better.


2. Preparation

Zabbix Related Resources Download page for Https://www.zabbix.com/download, can be installed in this individual need to download.

2.1zabbix Server-side

Provides a Zabbix server installation package for various types of operating systems and virtual machine files that have been configured on the virtual machine, as well as source code for the hands-on people to compile their own installation, where we compile the installation ourselves, download the latest version of Zabbix server version, To 3.4.3,:https://ncu.dl.sourceforge.net/project/zabbix/zabbix%20latest%20stable/3.4.3/zabbix-3.4.3.tar.gz

2.2zabbix Linux Client

Here, you can download the compiled client directly:

2.3zabbix Windows Client

Download the compiled client here: Https://www.zabbix.com/downloads/3.4.0/zabbix_agents_3.4.0.win.zip.

3. Compiling the installation

3.1Zabbix Server Compilation Installation

First upload the Zabbix server source code to the server (which can be uploaded or downloaded with wget on a Linux server), assuming it is placed under the/root path.

First create the Zabbix runtime account:

Groupadd Zabbix

Useradd-g Zabbix Zabbix


Then extract the Zabbix source code:

TAR-ZXVF zabbix-3.4.3.tar.gz

cd/root/zabbix-3.4.3

You can view the compilation configuration parameters for Zabbix:

./configure–help

Some of the more important parameters are:

--prefix=prefix Specifying the installation location

--enable-server Enable server Functionality

--enable-agent Enabling Client Features

--enable-java Enabling the Java Gateway feature

--enable-ipv6 Enable IPV6

--with-mysql support MySQL

--WITH-LIBXML2 Supporting XML

--WITH-NET-SNMP Support NET-SNMP

--WITH-SSH2 Support SSH2

--with-libcurl supports Curl


Before we compile, we need to install some libraries, mainly in the process of compiling and running, and installing the commands as follows:

Yum install net-snmp net-snmp-devel net-snmp-utils libssh2 libssh2-devel openldap openldap-devel UnixODBC unixodbc-devel OpenIPMI openipmi-devel libevent libevent-devel-y


If you do not install these libraries, you can see the following error when you run the following configure command:

CONFIGURE:ERROR:NET-SNMP Library not found

Configure:error:SSH2 Library not found

Configure:error:unixODBC Library not found

Configure:error:SSH2 Library not found


Because we've installed MySQL, PHP, and Java in previous articles in this series, we only need to specify the path here, such as:

--with-mysql=/usr/local/mysql-5.7.18/bin/mysql_config


We now install Zabbix server is the Centos7,linux kernel version of 3.10, we have installed MySQL5.7 and PHP5.6.30, so our compilation configuration is:

./configure--prefix=/usr/local/zabbix--enable-server--enable-agent--enable-ipv6--enable-java--with-mysql=/usr/ Local/mysql-5.7.18/bin/mysql_config--with-net-snmp=/usr/bin/net-snmp-config--with-libcurl--WITH-LIBXML2-- WITH-OPENIPMI--WITH-UNIXODBC--with-ldap--with-ssh2\


If there is no accident, it will compile successfully.


Off-topic: In this series on the compilation of the installation of memcached when the installation of Libevent, when the designation Libevent installed in the/usr/local/libevent, I in the spirit can less a matter of attitude, Through the parameters to specify the location of the libevent, no longer install libevent, the results compiled error, said to be unable to find event.h, my configure parameters are as follows:

./configure--prefix=/usr/local/zabbix--enable-server--enable-agent--enable-ipv6--enable-java--with-mysql=/usr/ Local/mysql-5.7.18/bin/mysql_config--with-net-snmp=/usr/bin/net-snmp-config--with-libcurl--WITH-LIBXML2-- WITH-OPENIPMI--with-unixodbc--with-ldap--with-ssh2--with-libevent=/usr/local/libevent--with-libevent-include=/ Usr/local/libevent/include/event2--with-libevent-lib=/usr/local/libevent/lib

Here to toss a long time, their own many attempts, including on the official website and online search for answers are no results, eventually reluctantly choose Yum Install libevent libevent-devel to solve the problem.


3.2zabbix-agent Compiling and installing

For Zabbix clients, you can also compile the installation, install the compiled installation package directly under Linux, install it using the Yum install method, or unzip the installation as if you downloaded the package under Windows.

This article describes the installation process under Windows:

Download the compressed package as mentioned earlier, unzip it to the Windows host with the installation of the C disk, the extracted path is: C:\zabbix_agents_3.4.0.win, in C:\zabbix_agents_3.4.0.win\ The bin directory has Win32 and Win64 two directories corresponding to x86 and x64 schemas, respectively, because my machine is Win7 X64, so the commands installed under the command window are:

CD C:\zabbix_agents_3.4.0.win\bin\win64

Zabbix_agentd.exe-c C:\zabbix_agents_3.4.0.win\conf\zabbix_agentd.win.conf–i

After successful execution of the above command, you will have one more Zabbix agent service in the Windows system service.

The command to start Zabbix_agentd is:

Zabbix_agentd.exe-c C:\zabbix_agents_3.4.0.win\conf\zabbix_agentd.win.conf–s


4. Configuration

4.1 Initializing the Zabbix database

First, make sure that MySQL is started, and then log on to MySQL.

[Email protected] ~]#/usr/local/mysql-5.7.18/bin/mysql-u root-p

Enter Password:


Then create the Zabbix database, Zabbix the database initialization file in the/root/zabbix-3.4.3/database directory (note that this article is to extract the Zabbix source package to/root/ zabbix-3.4.3 directory, if not this directory to modify according to the actual situation, the directory under the name of the folder Zabbix support DB2, Oracle, MySQL, PostgreSQL and SQLite database, when if the number of monitoring devices, It is recommended that you do not use SQLite.

Here's how to create a database and initialize the database:

Mysql> CREATE database Zabbix character set UTF8 collate utf8_bin;

Mysql> Grant all privileges the zabbix.* to [e-mail protected] identified by ' Zabbixpassword '; Flush privileges;

Mysql> quit;

Attention:

Please change the ' Zabbixpassword ' in the SQL statement above to the actual database password, and keep this password in mind, and use it later.

If "Skip-name-resolve" is configured in my.cnf, which prevents MySQL from resolving the domain name to IP, then the authorization statement needs to be changed to: "Grant all privileges on zabbix.* to [email protected] ' 127.0.0.1 ' identified by ' Zabbixpassword '; Flush privileges; "

Now that the database has been created, but not initialized, the following is the Zabbix MySQL account you just created to complete the initialization of the Zabbix database.

/usr/local/mysql-5.7.18/bin/mysql-u zabbix-penter password:mysql> Use zabbix;mysql> source/root/zabbix-3.4.3/ Database/mysql/schema.sql;mysql> source/root/zabbix-3.4.3/database/mysql/images.sql;mysql> source/root/ Zabbix-3.4.3/database/mysql/data.sql;


At this point, the completion of the MySQL database initialization, you can do Zabbix management system installation.


4.2Zabbix Server Configuration

In the previous compilation installation process, we specified that the Zabbix installation path is/usr/local/zabbix, and there are subfolders in this directory:

Etc folder for storing Zabbix server configuration file, the main two, respectively, is zabbix_server.conf and zabbix_agentd.conf;

The Sbin folder is used to store Zabbix server and Agent startup files.

Zabbix monitoring and monitoring programs that have been compiled and installed do not function properly and need to be configured.

The zabbix_server.conf file stores the Zabbix server as a service-side listener configuration, mainly in the following areas need to be modified:

Dbname=zabbix database name, please modify it according to the actual situation

Dbuser=zabbix database users, please modify according to the actual situation

Dbpassword=zabbix Database Password, please modify it according to the actual situation

The zabbix_agentd.conf needs to be configured are:

server=127.0.0.1

serveractive=127.0.0.1

Hostname=zabbix Server


Here are the configuration of two files on the Zabbix server:

It is necessary to note that Zabbix_server and ZABBIX_AGENTD two programs have different uses, so to understand (in fact, some situations will be a little differently): Zabbix_server as a server process, receiving clients ZABBIX_ Agentd sent over the data, and ZABBIX_AGENTD is responsible for the local monitoring metrics data sent to the zabbix_server process, so to monitor the Zabbix server itself, the performance of the Linux system, also need to start zabbix_agentd. The two programs use the zabbix_server.conf and zabbix_agentd.conf two profiles respectively, and only need to install and configure ZABBIX_AGENTD on a non-Zabbix server when it is deployed again.


With the above configuration, you can start Zabbix_server and zabbix_agentd from the command line.

Start Zabbix_server:

/usr/local/zabbix/sbin/zabbix_server

Start Zabbix_agentd:

Usr/local/zabbix/sbin/zabbix_agentd


I am starting the Zabbix_server times following error:

Error while loading shared Libraries:libmysqlclient.so.20:cannot open Shared object file:no such file or directory

The Find ibmysqlclient.so.20 is located in the/usr/local/mysql-5.7.18/lib/directory, so a link is created:

Ln-s/usr/local/mysql-5.7.18/lib/libmysqlclient.so.20/usr/lib64/libmysqlclient.so.20

The error disappears.


In addition, it is not convenient to manually start Zabbix_server and zabbix_agentd in the actual work scenario, so it can be registered as a service, and a script that registers it as a system service is stored under the compression package when the installation Zabbix is compiled. In this article, this directory is:/ROOT/ZABBIX-3.4.3/MISC/INIT.D, in this directory can find Ubuntu and other system names but not the name Redhat and CentOS, but people familiar with Linux will know that Fedora, RHEL /red Hat Enterprise Linux and CentOS, and choose the file under/root/zabbix-3.4.3/misc/init.d/fedora/core5.

Copy the Zabbix_server and Zabbix_agentd files in the/root/zabbix-3.4.3/misc/init.d/fedora/core5 directory to the/etc/init.d/directory and modify the Zabbix_ The path information for the server and Zabbix_agentd, and then chmod 755/etc/init.d/zabbix_*, and executes the following command:

Chkconfig Zabbix_server on

Chkconfig Zabbix_agentd on

This way Zabbix_server and ZABBIX_AGENTD can be started with the system.

4.3 Installing the Zabbix system

Because the Zabbix compressed package is unzipped in/root/zabbix-3.4.3, there is a frontends directory under this directory, which contains the Zabbix Web management interface, which can be copied to the Web server directory:

Mkdir/usr/local/nginx-1.12.0/html/zabbix

Cp-r/root/zabbix-3.4.3/frontends/php/*/usr/local/nginx-1.12.0/html/zabbix

Note: In this series of the 5th describes the installation of Nginx, in this series of the 7th describes the Nginx and PHP-FPM integration, Nginx installed in the/usr/local/nginx-1.12.0/directory.

Now you can install the Zabbix Web Management system, in order to avoid the virtual machine and host frequent switching trouble, we recommend that the virtual machine is bridged to the host network, and then on the host to access the virtual machine on the web system, The virtual machine IP that installs Zabbix here is 192.168.0.108, first open the URL http://192.168.0.108/zabbix/in the host, you will see the Welcome interface of Zabbix:

Click Next to install the environment check, if you do not meet the installation conditions, you will see the error message, as shown in:

Most of the time will give advice on how to correct, according to the recommendations to modify, when the installation conditions to see the following interface:

Click Next to configure the database connection information as shown in:

Here is a reminder, if you configure "Skip-name-resolve" in my.cnf, then please replace the above "localhost" to 127.0.0.1.

Click Next to configure the Zabbix host information as shown in:

Click Next to perform the pre-installation configuration information check as shown in:

Click Next to start the installation, if the/usr/local/nginx-1.12.0/html/zabbix/conf/folder permissions are not enough, you may encounter the following prompt:

In this case there are several ways, one is to give the folder to the current web system to use the role of write permission, one is to follow the above prompts to download the file down to the specified location.

Solve the above problem can complete the installation, the interface is as follows:

This completes the installation of the Zabbix server.

5. Inspection configuration

In the host open Zabbix home http://192.168.0.108/zabbix/index.php, login, note Zabbix default management account and the corresponding password is: Admin/zabbix (Linux is case-sensitive, Also remember to log in the system after the first thing is to change the default password), login after the interface as follows:

There is no data above, and at the very bottom you can see the hint "Zabbix server is running:the information displayed might not being current".

5.1 Changing the password and system language

By default Zabbix uses English, for most people is not friendly, can be modified in the Http://192.168.0.108/zabbix/profile.php Web page, but also in this interface can modify their login password, as shown in:

Select "ZH-CN" at language and click the Update button, the user interface will become Chinese.


5.2 Solve Chinese garbled problem

After switching to Simplified Chinese, you will find that in the "watch"-"graphics" interface some text is garbled, need to use the following methods to solve:

Upload the font file of Simkai.ttf in Windows system to the Zabbix Web system directory, Simkai.ttf this file in Win7 location: C:\Windows\Fonts\simkai.ttf, will be uploaded to/usr/ Local/nginx-1.12.0/html/zabbix/fonts directory (This depends on the installation location).

Then switch to/usr/local/nginx-1.12.0/html/zabbix/at the command line and execute the following command:

Sed-i ' s/dejavusans/simkai/g './include/defines.inc.php

At this point, the Chinese garbled problem solved, as shown in:

5.3 Adding a host

First install the corresponding agent client on the monitored host and configure the agentd.conf file (refer to the configuration on Zabbix server).

Then through "Configuration"-"host"-"Create host" can open the Create Host page, to fill in the information as shown in:

Set the template that needs to be associated in the next action, by setting the association template to determine what data will be monitored, as shown in:

The above steps complete the creation of the monitored host.

5.4 Template Management

Zabbix Default provides some templates, but in fact these templates are not enough to meet our flexible monitoring needs, if the Zabbix is skilled enough to create templates on their own, but for the first-time users of this requirement is somewhat high, so you can also from the https:// share.zabbix.com/download Some templates that have been verified by others, which is the webpage:

You can quickly find a template that suits you according to the classification.


5.5Zabbix API

Zabbix provides API services for common operations and queries through the API, and the Zabbix API can be accessed through http://localhost/zabbix/api_jsonrpc.php on the Zabbix server. The data received and responded to by this API are all JSON-used. I previously used C # to develop a mail notification system for the timing of query Zabbix status, if the exception to send notification messages, the message format is as follows:

This way, there is no need to constantly monitor the Web page, there will be an exception to receive email notification.

6. Summary

This article describes how to install Zabbix in CentOS7, an enterprise-class open source IT equipment monitoring system, for a large number of IT equipment and applications need to monitor the team, the use of a good monitoring tool can greatly reduce the pressure of operations personnel, at least during my tenure as a public company Informatization VP, Through this tool I basically did not let the OPS to report to me the company's network equipment, servers and network anomalies, greatly facilitate the operation and maintenance personnel. However, due to the time limit, there was no chance to detail the more detailed usage of Zabbix, including the one I wrote for Zabbix based on Zabbix API query service, encountered abnormal situation in time to the operation and maintenance personnel alarm monitoring tool.


Statement: This article started in my personal subscription number: Zhoujinqiaoit, will be at the same time in my csdn, 51CTO and Oschina three blog posts, I will be responsible for answering around here.


Developer Linux: CentOS7 installation configuration IT equipment monitoring system Zabbix

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.