centos7.4-Construction of Zabbix monitoring system
Directory
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
- Linux Service Side One
IP Address: 192.168.80.10
Required Software: php-bcmath-5.4.16-42.el7.x86_64
Php-mbstring-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
- Linux Client One
IP Address: 192.168.80.20
Note: Clients also need to be able to sisu network, can download zabbix-agent service
- Win7 client One (for testing)
IP Address: 192.168.80.2
The second section configures the server side
First step: RPM Build lamp architecture (local yum repository)
[email protected] ~]# Yum install-y \
HTTPD \
Mariadb-server mariadb \
PHP \
Php-mysql \
PHP-GD \
Libjpeg\
PHP-LDAP \
PHP-ODBC \
Php-pear \
Php-xml \
PHP-XMLRPC \
Php-mhash
[[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
Reload
[Email protected] ~]# vi/var/www/html/index.php
<?php
Phpinfo ();
?>
Save exit
Win7 Access http://192.168.80.10
[[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
<?php
$link =mysql_connect (' 192.168.80.10 ', ' Zabbix ', ' admin123 ');
if ($link) echo "else echo "fail!!";
Mysql_close ();
?>
Save exit
Win7 Access http://192.168.80.10
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 http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm 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/defines.inc.php//fixed 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 http://192.168.80.10/zabbix/
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 http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
[email protected] ~]# Yum install-y zabbix-agent
[[email protected] ~]# vi/etc/zabbix/zabbix_agentd.conf//edit config file
Modify the following content:
server=192.168.80.10
serveractive=192.168.80.10
Hostname=client
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 smtp=smtp.163.com
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 mailx.sh//write e-mail script
#!/bin/bash
#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/mailx.sh
[Email protected] alertscripts]# chown-r zabbix.zabbix/usr/lib/zabbix/
[Email protected] alertscripts]#/mailx.sh [email protected] topic "content"//test Outgoing mail script is working correctly
View Email:
Test success
Step Two: Web page configuration
- Management-Alarm Media type-Create media type
Name: Mail-test
Type: Script
Script Name: mailx.sh
Script Parameters://Add the following three parameters
{ALERT. SENDTO}
{ALERT. SUBJECT}
{ALERT. MESSAGE}
- Management-Users-click admin-Alarm Media
- 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 http://192.168.80.20
[[email protected] ~]# systemctl start sshd
Three: Test mail alarm
- 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
- 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