Deployment of monitoring service zabbix

Deployment of monitoring service zabbix

Articles Catalogue

1. Introduction to ZABBIX

abbix is an enterprise-level open source solution based on WEB interface to provide distributed system monitoring and network monitoring functions.

zabbix can monitor all kinds of network parameters to ensure the safe operation of the server system, and provide flexible notification mechanism to enable system administrators to quickly locate and solve various problems.

zabbix consists of two parts, zabbix server and optional component zabbix agent

zabbix server can provide remote server/network status monitoring, data collection and other functions through SNMP, zabbix agent, ping, port monitoring and other methods. It can run on Linux, Ubuntu, Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X and other platforms.

zabbix agent needs to be installed on the monitored target server, which mainly completes the collection of hardware information or memory, CPU and other information related to the operating system.

zabbix server can monitor the service status of remote server independently; it can also cooperate with zabbix agent, poll zabbix agent to receive monitoring data actively (agent mode), and passively receive data sent by zabbix agent (trapping mode).
In addition, zabbix server also supports SNMP (v1,v2), which can be used in conjunction with SNMP software (such as net-snmp).

2. Characteristics of ZABBIX

The main features of zabbix are as follows:

  • Simple installation and configuration, low learning cost
  • Support multi-language (including Chinese)
  • Free Open Source
  • Automatic Discovery Server and Network Device
  • Distributed Monitoring and WEB Centralized Management Function
  • Can be monitored without an agent
  • User Security Authentication and Soft Authorization
  • Setting or viewing the monitoring results through the WEB interface
  • Notification functions such as email

The main functions of Zabbix are:

  • CPU Load
  • Memory usage
  • Disk usage
  • Network status
  • Port monitoring
  • Log monitoring

3. zabbix configuration file

There are two types of zabbix configuration files:

  • Server-side configuration file (/usr/local/etc/zabbix_server.conf)
  • Client Configuration File (/usr/local/etc/zabbix_agent d.conf)
  • ZABBIX proxy configuration file (/usr/local/etc/zabbix_proxy.conf)

Common configuration parameters for server-side configuration file zabbix_server.conf:

parameter Effect
LogFile Setting the server log file storage path
ListenIP Setting up the server to listen on IP
ListenPort Setting the port number of the server listening
PidFile Setting up File Storage Path of Server Process Document
DBHost Specify the database server IP for zabbix
DBName Specify the database library name used by zabbix
DBUser Specify the zabbix database login user
DBPassword Specify the zabbix database login password
DBPort Specify the port number of zabbix database
User Set up which user zabbix runs as
AlertScriptsPath Setting the Storage Path of Alert Script
ExternalScripts External script storage path

Common configuration parameters for client configuration file zabbix_agent d.conf:

parameter Effect
Server Specify the IP or domain name of the zabbix server
ServerActive Specify the IP or domain name of the zabbix server
Hostname Specify the host name of the native machine, which must be consistent with the web interface configuration item
UnsafeUserParameters Whether or not to enable custom monitors with an optional value of 1/0
UserParameter Specify custom monitoring script parameters
LogFile Setting the Client Log File Storage Path

4. Deployment of zabbix

Environmental description:

Environmental Science IP Applications to be installed
The server 192.168.30.128 lamp architecture
zabbix server
zabbix agent
Client 192.168.20.128 zabbix agent

lamp architecture address https://blog.csdn.net/sky 1791/article/details/99181344

4.1 zabbix Server Installation

Install dependency packages
[root@swk yum.repos.d]# yum -y install net-snmp-devel libevent-devel

//Download zabbix
[root@swk ~]# cd /usr/src/
[root@swk src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz

//decompression
[root@swk src~]# tar xf zabbix-4.0.3.tar.gz

//Create zabbix users and groups
[root@swk ~]# groupadd -r zabbix
[root@swk ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix

//Configuring zabbix database
[root@swk ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected, 2 warnings (3.66 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.87 sec)

mysql> quit
Bye

[root@swk ~]# cd /usr/src/zabbix-4.0.3/database/mysql/
[root@swk mysql]# ls
data.sql  images.sql  Makefile.am  Makefile.in  schema.sql
[root@swk mysql]# mysql -uzabbix -p123456 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@swk mysql]# mysql -uzabbix -p123456 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@swk mysql]# mysql -uzabbix -p123456 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

//Compile and install zabbix
[root@swk mysql]# cd /usr/src/zabbix-4.0.3
[root@swk zabbix-4.0.3]#./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@swk zabbix-4.0.3]# make install

4.2 zabbix server configuration

Modify the server-side configuration file
//Setting up database information
[root@swk zabbix-4.0.3]# cd /usr/local/etc/
[root@swk etc]# ls
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d
[root@swk etc]# vim zabbix_server.conf
DBPassword=zabbix123!     \\Set up zabbix Database Connection Password

//Start zabbix_server and zabbix_agent D
[root@swk etc]# zabbix_server
[root@swk etc]# zabbix_agentd
[root@swk etc]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128             *:22                          *:*                  
LISTEN     0      100     127.0.0.1:25                          *:*                  
LISTEN     0      128             *:10050                       *:*                  
LISTEN     0      128     127.0.0.1:9000                        *:*                  
LISTEN     0      128            :::80                         :::*                  
LISTEN     0      128            :::22                         :::*                  
LISTEN     0      100           ::1:25                         :::*                  
LISTEN     0      80             :::3306                       :::*    

4.3 Installation and Configuration of Zabbix Server-side web Interface

modify/etc/php.ini Configuration and restart php-fpm
[root@swk ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@swk ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@swk ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@swk ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@swk ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

[root@swk ~]# cd /usr/src/zabbix-4.0.3
[root@swk zabbix-4.0.3]# ls
aclocal.m4  conf           configure.ac    include      Makefile.in  sass
AUTHORS     config.guess   COPYING         INSTALL      man          src
bin         config.log     database        install-sh   misc         --with-libcurl
build       config.status  depcomp         m4           missing      --with-libxml2
ChangeLog   config.sub     --enable-agent  Makefile     NEWS         --with-mysql
compile     configure      frontends       Makefile.am  README       --with-net-snmp
[root@swk zabbix-4.0.3]# mkdir /usr/local/apache/htdocs/zabbix
[root@swk zabbix-4.0.3]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@swk zabbix-4.0.3]# chown -R apache.apache /usr/local/apache/htdocs

//Configure apache virtual host
//Add the following at the end of the configuration file
[root@swk ~]# vim /etc/httpd24/httpd.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName www.wangqing.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

//Set the permissions of the zabbix/conf directory to allow ZABBIX to generate the configuration file zabbix.conf.php
[root@swk ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@swk ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwxrwx. 2 apache apache 81 12 February 20, 2018 /usr/local/apache/htdocs/zabbix/conf

//Restart apache
[root@swk ~]# apachectl -t
Syntax OK
[root@swk ~]# apachectl stop
[root@swk ~]# apachectl start
[root@swk ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128             *:22                          *:*                  
LISTEN     0      100     127.0.0.1:25                          *:*                  
LISTEN     0      128             *:10050                       *:*                  
LISTEN     0      128     127.0.0.1:9000                        *:*                  
LISTEN     0      128            :::80                         :::*                  
LISTEN     0      128            :::22                         :::*                  
LISTEN     0      100           ::1:25                         :::*
LISTEN     0      80             :::3306                       :::*          

4.3.2 Install zabbix web interface

  • Modify / etc/hosts file to add mapping between domain name and IP
  • Visit the domain name on the browser. The domain name set in this article is zabbix.wangqing.com. You need to modify it to your own domain name.
  • Restore the permissions of the zabbix/conf directory to 755

Access the domain name on the browser for installation:

Client Configuration

Install dependency packages
[root@yasuo ~]# yum -y install net-snmp-devel libevent-devel libxml2-devel curl-devel pcre*

//Download zabbix
[root@yasuo src]# cd /usr/src/
[root@yasuo src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz
[root@yasuo src]# tar xf zabbix-4.0.3.tar.gz
[root@yasuo src]# ls
debug  kernels  zabbix-4.0.3  zabbix-4.0.3.tar.gz

//Create zabbix users and groups
[root@yasuo ~]# groupadd -r zabbix
[root@yasuo ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix

//Compile and install zabbix
[root@yasuo ~]# cd /usr/src/zabbix-4.0.3
[root@yasuo zabbix-4.0.3]# ./configure --enable-agent
[root@yasuo zabbix-4.0.3]# make install
[root@yasuo zabbix-4.0.3]# make install
[root@yasuo zabbix-4.0.3]# ls
aclocal.m4  compile        config.sub    depcomp     m4           misc     src
AUTHORS     conf           configure     frontends   Makefile     missing
bin         config.guess   configure.ac  include     Makefile.am  NEWS
build       config.log     COPYING       INSTALL     Makefile.in  README
ChangeLog   config.status  database      install-sh  man          sass

//Modify the server-side configuration file
//Setting up database information
[root@yasuo ~]# vim /usr/local/etc/zabbix_agentd.conf
Server=192.168.30.128
ServerActive=192.168.30.128
Hostname=yasuo

//Start zabbix_agent D
[root@yasuo ~]# zabbix_agentd
[root@yasuo ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128             *:22                          *:*                  
LISTEN     0      100     127.0.0.1:25                          *:*                  
LISTEN     0      128             *:10050                       *:*                  
LISTEN     0      128            :::22                         :::*                  
LISTEN     0      100           ::1:25                         :::*                 


Keywords: Zabbix MySQL Apache Database

Added by bobdabuilder on Thu, 22 Aug 2019 14:53:15 +0300