Zabbix distributed monitoring system

catalogue

1.1 Zabbix structure

1. Server

2. Database storage

3. Web interface

4. Proxy server

5. Agent monitoring agent

1.2 case objectives

  1.3 case analysis

      1. Planning node

2. Foundation preparation

1.4 case implementation

  1. Basic environment configuration

(1) Host name configuration

  (2)Yum source configuration

(3) Install the LAMP+Zabbix service (executed on the ZABBIX server node)

two   Configure and start the Zabbix service

(1) Start httpd service

(2) Start and configure the database service

(3) Set time zone

(4) Modify the Zabbix configuration file and start

   3.   Using Zabbix services

(1) Login interface

(2) Chinese interface

(3) Add monitored machine

(4) Monitoring machine

1.1 Zabbix structure

Zabbix consists of several main software components. The functions of these components are as follows.

1. Server

ZABBIX server is the core component of monitoring agent reporting system availability, system integrity and statistics. ZABBIX server is the core storage of all configuration information, statistics and operation data.

2. Database storage

All configuration information and data collected by Zabbix are stored in the database.

3. Web interface

In order to easily access Zabbix anywhere and on any platform, Zabbix provides a Web-based interface. This interface is a part of Zabbix Server. It usually runs on the same physical machine as Zabbix Server.

If you use SQLite, the Zabbix Web interface must run on the same physical machine as the Zabbix Server.

4. Proxy server

Zabbix Proxy can collect performance and availability data for Zabbix Server. The Proxy proxy server is an optional part of Zabbix software deployment. Of course, the Proxy server can help a single Zabbix Server share the load pressure.

5. Agent monitoring agent

Zabbix Agents monitoring agent is deployed on the monitoring target, which can actively monitor local resources and applications, and report the collected data to Zabbix Server.

1.2 case objectives

  (1) Understand Zabbix distributed monitoring system.

  (2) Build Zabbix distributed monitoring system.

  (3) Zabbix distributed monitoring system is used.

  1.3 case analysis

      1. Planning node

Zabbix distributed planning node, as shown in the figure.

IP

host name

node

192.168.49.8

zabbix-server

Server node

192.168.49.38

zabbix-agent

Agent node

2. Foundation preparation

Using CentOS_7.2_x86_64_XD.qcow2 image, flavor uses 4vCPU/8GB memory / 100GB hard disk to create virtual machine. The Yum source uses the zabbix folder provided.

1.4 case implementation

  1. Basic environment configuration

(1) Host name configuration

Modify the host name of the Server node to ZABBIX Server

#hostname zabbix
#bash
#hostnamectl
Static hostname: zabbix-server
         Icon name: computer-vm
           Chassis: vm
        Machine ID: dae72fe0cc064eb0b7797f25bfaf69df
           Boot ID: bf8e7d1eef924a008869a5275404abbc
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.el7.x86_64
      Architecture: x86_64

The Agent node modifies the host name to ZABBIX Agent

#hostname zabbix-agent
#bash
#hostnamectl
Static hostname: zabbix-agent
         Icon name: computer-vm
           Chassis: vm
        Machine ID: dae72fe0cc064eb0b7797f25bfaf69df
           Boot ID: 31c2078162b3477fb3deb9195092e135
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.el7.x86_64
      Architecture: x86_64

  (2)Yum source configuration

  Centos-7-x86 to be provided_ Upload the 64-dvd-1511.iso image and zabbix folder to the / opt directory of the zabbix server node.

Create the mount directory on the ZABBIX server node

#mkdir /opt/centos

CentOS-7-x86_64-DVD-1511.iso mount to / opt/centos directory

#cd /opt/
#ll
total 4228100
drwxr-xr-x 2 root root          6 Oct  4 18:43 centos
-rw-r--r-- 1 root root 4329570304 Feb 26  2018 CentOS-7-x86_64-DVD-1511.iso
drwxr-xr-x 3 root root       4096 Oct  4 18:46 zabbix
#mount CentOS-7-x86_64-DVD-1511.iso centos/
mount: /dev/loop0 is write-protected, mounting read-only

After mounting the iso file, move all files in the / etc/yum.repo.d directory to / media.

# mv /etc/yum.repos.d/* /media/

Create the local.repo file in the / etc/yum.repo.d directory. The contents of the file are as follows

# cat /etc/yum.repos.d/local.repo 
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[zabbix]
name=zabbix
baseurl=file:///opt/zabbix
gpgcheck=0
enabled=1

So far, the Yum source of the ZABBIX server node has been configured.

Next, configure the Yum source of the ZABBIX agent node. First, install the vsftpd service on the ZABBIX server node.

# yum install vsftpd -y 

Modify the configuration file vsftpd.conf of vsftpd service, and add a line of code at the top of the configuration file. The command is as follows

# vi /etc/vsftpd/vsftpd.conf
anon_root=/opt
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file

Save the changes and exit. Start the vsftpd service. The command is as follows

# systemctl start vsftpd
# systemctl status vsftpd
vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled)
   Active: active (running) since Fri 2019-10-04 19:04:54 UTC; 5s ago
  Process: 10014 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 10015 (vsftpd)
   CGroup: /system.slice/vsftpd.service
           └─10015 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

Oct 04 19:04:54 zabbix-server systemd[1]: Started Vsftpd ftp daemon.

On the ZABBIX agent node, first move all the files in / etc/yum.repo.d directory to / media directory, and then create the local.repo file. The contents of the file are as follows

# mv /etc/yum.repos.d/* /media/
# vi /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=ftp://172.16.51.5/centos
gpgcheck=0
enabled=1
[zabbix]
name=zabbix
baseurl=ftp://172.16.51.5/zabbix
gpgcheck=0
enabled=1

So far, the Yum sources of the two nodes have been configured.

(3) Install the LAMP+Zabbix service (executed on the ZABBIX server node)

Install the httpd service with the following command

# yum install httpd -y

Install the database service with the following command

# yum install -y mariadb-server mariadb

Install the Zabbix service with the following command

# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server

Upgrade the trousers service with the following command

# yum install trousers -y

So far, the software package required by Zabbix service has been installed.

two   Configure and start the Zabbix service

(1) Start httpd service

Use the command to start the httpd service, set the startup self startup, and finally check the running status. The command is as follows

# systemctl start httpd
# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Fri 2019-10-04 19:34:32 UTC; 27s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 10215 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─10215 /usr/sbin/httpd -DFOREGROUND
           ├─10217 /usr/sbin/httpd -DFOREGROUND
           ├─10218 /usr/sbin/httpd -DFOREGROUND
           ├─10219 /usr/sbin/httpd -DFOREGROUND
           ├─10220 /usr/sbin/httpd -DFOREGROUND
           └─10221 /usr/sbin/httpd -DFOREGROUND

Oct 04 19:34:31 zabbix-server systemd[1]: Starting The Apache HTTP Server...
Oct 04 19:34:32 zabbix-server httpd[10215]: AH00557: httpd: apr_sockaddr_info_get() fa...er
Oct 04 19:34:32 zabbix-server httpd[10215]: AH00558: httpd: Could not reliably determi...ge
Oct 04 19:34:32 zabbix-server systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

(2) Start and configure the database service

Start the database service and set the startup self startup. The commands are as follows

# systemctl start mariadb
# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

Log in to the database and create zabbix Library (Chinese coding format). The commands are as follows

# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, 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.00 sec)

Grant zabbix user access. The command is as follows

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix'; 
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; 
Query OK, 0 rows affected (0.00 sec)

Exit the database, enter the / usr/share/doc/zabbix-server-mysql-3.4.15/ directory, and import the database file. The command is as follows

MariaDB [(none)]> Ctrl-C -- exit!
Aborted
# cd /usr/share/doc/zabbix-server-mysql-3.4.15/
# ll
total 2120
-rw-r--r-- 1 root root      98 Nov 12  2018 AUTHORS
-rw-r--r-- 1 root root  866545 Nov 12  2018 ChangeLog
-rw-r--r-- 1 root root   17990 Nov 12  2018 COPYING
-rw-r--r-- 1 root root 1267039 Nov 12  2018 create.sql.gz
-rw-r--r-- 1 root root      52 Nov 12  2018 NEWS
-rw-r--r-- 1 root root    1062 Nov 12  2018 README
# zcat create.sql.gz |mysql -uroot zabbix

At this point, the database configuration is complete.

(3) Set time zone

Edit the / etc/php.ini file and set the time zone. Under the [Date] field, set date.timezone=PRC. The command is as follows

# vi /etc/php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = PRC

Edit the / etc/httpd/conf.d/zabbix.conf file, modify the time zone, and modify php_value date.timezone is Asia/Shanghai, and the command is as follows

# vi /etc/httpd/conf.d/zabbix.conf
<IfModule mod_php5.c>
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/Shanghai
    </IfModule>

After modifying the configuration file, restart the httpd service. The command is as follows

# systemctl restart httpd

(4) Modify the Zabbix configuration file and start

Modify / etc/zabbix/zabbix_server.conf configuration file. The modified configuration file is as follows:

# vi /etc/zabbix/zabbix_server.conf
# grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf 
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
91:DBHost=localhost
100:DBName=zabbix
116:DBUser=zabbix
124:DBPassword=zabbix
132:DBSocket=/var/lib/mysql/mysql.sock
330:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
447:Timeout=4
489:AlertScriptsPath=/usr/lib/zabbix/alertscripts
499:ExternalScripts=/usr/lib/zabbix/externalscripts
535:LogSlowQueries=3000

Start the Zabbix service with the following command

# systemctl start zabbix-server

Check the port number and verify whether the service port 10051 of ZABBIX server exists. The command is as follows

# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      10611/zabbix_server 
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      10510/mysqld        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      975/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      886/master          
tcp6       0      0 :::10051                :::*                    LISTEN      10611/zabbix_server 
tcp6       0      0 :::80                   :::*                    LISTEN      10579/httpd         
tcp6       0      0 :::21                   :::*                    LISTEN      10015/vsftpd        
tcp6       0      0 :::22                   :::*                    LISTEN      975/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      886/master

So far, the server side of Zabbix monitoring service has been configured. Next, you need to operate in the Web interface.

three   Using Zabbix services

(1) Login interface

Access 172.16.51.5/zabbix in the browser, enter the Zabbix installation wizard, click the "Next step" button in the lower right corner to enter the next operation, as shown in the figure

   

  Display PHP version information and other contents, and then click the "Next step" button in the lower right corner to enter the next operation, as shown in the figure

Fill in the necessary information to connect to the database. The Password is zabbix, as shown in the figure  , After filling in, click the "Next step" button in the lower right corner to proceed to the Next step.

  Fill in the details of the Zabbix server, as shown in the figure. The Name field can be filled in freely, which is to give a Name to the monitoring platform. Then click the "Next step" button in the lower right corner to proceed to the Next step.

 

  The platform configuration overview is shown in the figure. After confirmation, click the "Next step" button in the lower right corner.

  Install Zabbix. After the installation is successful, click the "Finish" button in the lower right corner to end the installation, as shown in the figure.

  Click Finish to enter the login interface and log in with the default user name and password Admin/zabbix, as shown in the figure.

  Enter the Zabbix home page, as shown in the figure.

(2) Chinese interface

Click the avatar button in the upper right corner to enter the setting interface, as shown in the figure.

  Change the "Language" column to "chinaexe (zh CN)", and then click the "Update" button below, as shown in the figure

  The Zabbix monitoring interface of the Chinese interface has been configured, as shown in the figure

(3) Add monitored machine

Go back to the ZABBIX agent node and install the ZABBIX agent service. The command is as follows

# yum install -y zabbix-agent

Modify / etc/zabbix/zabbix_agentd.conf configuration file, configure ZABBIX agent, and modify as follows

# vi /etc/zabbix/zabbix_agentd.conf 
# grep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
97:Server=172.16.51.5
138:ServerActive=172.16.51.5
149:Hostname=Zabbix-agent
267:Include=/etc/zabbix/zabbix_agentd.d/*.conf

Start the ZABBIX agent service and check whether port 10050 exists. The command is as follows

# systemctl start zabbix-agent
# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      10613/zabbix_agentd 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      979/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      899/master          
tcp6       0      0 :::10050                :::*                    LISTEN      10613/zabbix_agentd 
tcp6       0      0 :::22                   :::*                    LISTEN      979/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      899/master

Back to the Web interface, select the menu bar "configuration" → "host" → "create host" command, and you will jump to the page of configuring host as shown in the figure.

  Fill in the information and add the ZABBIX agent node to the monitored machine, as shown in the figure. Then click the Add button below.

After adding, as shown in the figure

 

  Add a monitoring item, click the name of "ZABBIX agent", and then click the "template" tab to add a template, as shown in the figure.

  Click the "select" button in the figure to add the monitoring template, check the check box you want to monitor in the jump interface, and then click the "select" button below, as shown in the following figure.

  After selecting the template, as shown in the figure.

  Click the Add button to display the linked template, and then click the update button, as shown in the figure.

  After clicking update, the ZABBIX agent node is added to the monitoring, as shown in the figure.

(4) Monitoring machine

Select the command "monitoring" → "graphics" in the top menu bar, select Linux server for the group, ZABBIX agent for the host, and select the monitoring items to be displayed for the graphics. Select CPU jumps here, as shown in the figure.

  For the host to be monitored, first install the Zabbix agent service, then modify the configuration file and start the service. Log in to the Web interface of Zabbix, add a host and add a monitoring template. After successfully added, the host can be monitored through the Zabbix interface.

Tags: Operation & Maintenance Zabbix cloud computing

Posted on Mon, 29 Nov 2021 03:25:10 -0500 by slurpee