Construction of Zabbix monitoring system under Linux monitoring chapter-centos7.4

Source: Internet
Author: User

centos7.4-Construction of Zabbix monitoring system

The first part of the experimental environment
The second section configures the server side
The third part configures the controlled end (monitored server)
Part IV Configure the mail alarm function
Part V Test Verification email alert

The first part of the experimental environment

    1. Linux Service Side One
      IP Address:
      Required Software: php-bcmath-5.4.16-42.el7.x86_64
      Note: Need public network environment (can sisu network), download the latest version of Zabbix service online
      Download fonts (italics) from Microsoft client to native
    2. Linux Client One
      IP Address:
      Note: Clients also need to be able to sisu network, can download zabbix-agent service
    3. Win7 client One (for testing)
      IP Address:

The second section configures the server side
First step: RPM Build lamp architecture (local yum repository)
[email protected] ~]# Yum install-y \

Mariadb-server mariadb \
Php-mysql \
Php-pear \
Php-xml \
[[email protected] ~]# vi/etc/httpd/conf/httpd.conf//Edit Apache configuration file
ServerName Server//#号去掉, changing host name
DirectoryIndex index.html index.php//Add index.php
Save exit
[[email protected] ~]# vi/etc/php.ini edit php config file
Date.timezone = PRC//Modify time zone, remove ";" Comments
Save exit
[Email protected] ~]# Systemctl stop Firewalld
[Email protected] ~]# Setenforce 0
[Email protected] ~]# systemctl start Httpd.service
[Email protected] ~]# systemctl start Mariadb.service
[Email protected] ~]# NETSTAT-ANPT | grep 80
[Email protected] ~]# NETSTAT-ANPT | grep 3306

[[email protected] ~]# mysql_secure_installation//Initialize database configuration
Create Root Account login password
Remove Anonymous Users
Allow root users to Telnet

To remove a test database
[Email protected] ~]# vi/var/www/html/index.php
Phpinfo ();
Save exit
Win7 Access

[[email protected] ~]# mysql-u root–p//root User login database for configuration
CREATE DATABASE Zabbix Character set UTF8 collate utf8_bin; Create a Zabbix database
GRANT all on Zabbix.
To ' Zabbix ' @ '% ' of ' identified by ' admin123 '; Authorizing the Zabbix user to administer the Zabbix database
Flush privileges; Refresh Permissions

[Email protected] ~]# vi/var/www/html/index.php
$link =mysql_connect (' ', ' Zabbix ', ' admin123 ');
if ($link) echo "else echo "fail!!";
Mysql_close ();
Save exit
Win7 Access

Step two: Deploy the Zabbix service
[Email protected] ~]# RPM-IVH php-mbstring-5.4.16-42.el7.x86_64.rpm
[Email protected] ~]# RPM-IVH php-bcmath-5.4.16-42.el7.x86_64.rpm
[Email protected] ~]# RPM-IVH Download the latest version of Zabbix source (automatically generate Yum source) online
[[email protected] ~]# Yum install zabbix-server-mysql zabbix-web-mysql–y//install Zabbix services and plugins
[Email protected] ~]# zcat/usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | Mysql-uzabbix-p Zabbix//Generate database files, note passwords do not lose to root (admin123)
[[email protected] ~]# vi/etc/zabbix/zabbix_server.conf//edit config file

Save exit
[[email protected] ~]# grep-n ' ^ ' [A-z]/etc/zabbix/zabbix_server.conf//Filter View configuration file

[[email protected] ~]# vi/etc/httpd/conf.d/zabbix.conf//Modify time zone

Save exit
[email protected] ~]# CP stkaiti.ttf/usr/share/zabbix/fonts/
[[email protected] ~]# vi/usr/share/zabbix/include/ the problem of garbled chart in Chinese
:%s/graphfont/kaiti/g//Replace All in italics
Save exit
[[email protected] ~]# Systemctl enable Zabbix-server//Set Zabbix boot
[[email protected] ~]# systemctl start zabbix-server//Start Zabbix Service
[Email protected] ~]# NETSTAT-ANPT | grep Zabbix

[[email protected] ~]# systemctl restart httpd//restart Apache service
Win7 Access

Set up Chinese environment: administrator-users-Click User-Language Settings

After the update, reopen the Web page

The third part configures the client (the managed server)
First step: Install the configuration zabbix-agent
Note: If the server also needs to be monitored by itself, it needs to be installed Zabbix-agent
[Email protected] ~]# RPM-IVH
[email protected] ~]# Yum install-y zabbix-agent
[[email protected] ~]# vi/etc/zabbix/zabbix_agentd.conf//edit config file
Modify the following content:
Save exit
[Email protected] ~]# grep-n ' ^ ' [A-z]/etc/zabbix/zabbix_agentd.conf

[[Email protected] ~]# service FIREWALLD stop
[Email protected] ~]# Setenforce 0
[Email protected] ~]# Systemctl enable zabbix-agent
[Email protected] ~]# systemctl restart Zabbix-agent
[Email protected] ~]# NETSTAT-ANPT | grep Zabbix

Step two: Increase the operation of the controlled host-web platform

Save add

Monitor HTTP, Ssh,linux itself system performance, add post-update

was successfully added

Part IV Configure the mail alarm function
Note: NetEase mailbox needs to open the client authorization code for third-party login

The authorization code is set to: abc123
First step: Server configuration
Install MAILX, and configure
[email protected] ~]# Yum install–y mailx
[Email protected] ~]# vi/etc/mail.rc
Finally add the following content:
Set [email protected]
Set [email protected]
Set smtp-auth-password=abc123
Set Smtp-auth=login
Save exit
[Email protected] ~]# echo "TTTTTTTT" | Mail-s "Testmail" [email protected]//test normal sending
View Email:

Test Normal
[Email protected] ~]# cd/usr/lib/zabbix/alertscripts/
[[Email protected] alertscripts]# VI e-mail script
#send Mail
messages=echo $3 | tr ‘\r\n‘ ‘\n‘
subject=echo $2 | tr ‘\r\n‘ ‘\n‘
echo "${messages}" | Mail-s "${subject}" $ >>/tmp/mailx.log 2>&1
Save exit
[Email protected] alertscripts]# Touch/tmp/mailx.log
[Email protected] alertscripts]# chown-r Zabbix.zabbix/tmp/mailx.log
[Email protected] alertscripts]# chmod +x/usr/lib/zabbix/alertscripts/
[Email protected] alertscripts]# chown-r zabbix.zabbix/usr/lib/zabbix/
[Email protected] alertscripts]#/ [email protected] topic "content"//test Outgoing mail script is working correctly
View Email:

Test success

Step Two: Web page configuration

    1. Management-Alarm Media type-Create media type

      Name: Mail-test
      Type: Script
      Script Name:
      Script Parameters://Add the following three parameters

    2. Management-Users-click admin-Alarm Media

    3. Configuration-action-Create action-Delete default tag, modify trigger condition

      (1) Action

      (2) operation

      (3) Restore operation

Part V Test Verification email alert
One: Server and client restart Zabbix service
[Email protected] alertscripts]# systemctl restart Zabbix-server
[Email protected] ~]# systemctl restart Zabbix-agent.service

Second: The terminal installs the HTTP service, opens the SSHD service
[email protected] ~]# Yum install-y httpd
[Email protected] ~]# vi/etc/httpd/conf/httpd.conf
ServerName Client
Save exit
[Email protected] ~]# echo "[Email protected] ~]# systemctl start httpd
[Email protected] ~]# NETSTAT-ANPT | grep httpd

Browser Access

[[email protected] ~]# systemctl start sshd

Three: Test mail alarm

    1. Simulated root partition usage exceeds 80%, test mail alerts
      Zabbix default disk partition usage exceeds 80% automatically alarms, so no configuration is necessary
      [Email protected] ~]# DF-HT

      [[email protected] ~]# dd If=/dev/zero of=test bs=100m count=70

      View Mailbox
    2. Analog off HTTP, SSH service
      [Email protected] ~]# Systemctl stop httpd
      [[email protected] ~]# Systemctl stop sshd
      View Mailbox

      Test success

Construction of Zabbix monitoring system under Linux monitoring chapter-centos7.4

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: 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.