Enterprise distributed monitoring zabbix deployment + installation troubleshooting local logon failures + test email alert

Source: Internet
Author: User
Tags snmp
--------------------- Overview ----------------------

ZabbixIs a highly integrated enterpriseOpen SourceNetwork Monitoring solution, similar to CACI and Nagios, provides distributed monitoring and a centralized web management interface. If the Monitored object supports SNMP or runs the zabbix_agents agent, the official website of zabbix is http://www.zabbix.com/software which can be freely downloaded and used.
SNMP protocol
Simple Network Management Protocol (SNMP) is composed of a set of network management standards, including an application layer protocol, database schema, and a group of resource objects. This protocol supports network management systems to monitor whether devices connected to the network have any management concerns. This Protocol is part of an Internet protocol cluster defined by the Internet Engineering team (IETF, Internet Engineering Task Force. The goal of SNMP is to manage software and hardware platforms produced by many manufacturers on the Internet. Therefore, SNMP is greatly affected by the internet standard network management framework. SNMP has been released to the third version, and its functions have been greatly enhanced and improved.


Zabbix provides common functions of business monitoring software:

  • Host performance monitoring
  • Network Device Performance Monitoring
  • Database performance monitoring
  • Monitoring of FTP and other common protocols
  • Flexible and customizable warning mechanisms
  • Allows users to send e-mail-based warnings to events to ensure that maintenance personnel can respond quickly to problems.
  • You can use the stored data to provide outstanding reports and real-time Graphical Data Processing, enabling centralized monitoring of Linux and Windows hosts on a 7 × 24 basis.
  • The monitored items can include CPU, memory, disk, Nic traffic, service availability, and other resources.


The zabbix monitoring component consists of three main components: zabbixserver, zabbix proxy, and Agent client. zabbixserver includes web GUI, database, and zabbix_server.

Zabbix collects data through the C/S model, and displays and configures data on the Web end in the B/S model mode.
?? Agent monitored: Host devices collect data by installing the agent and send it to the server. network devices collect data by using SNMP and send it to the server.
Server monitoring: collects data sent by SNMP and agent and writes the data to the background database (for example, MySQL and Oracle). The data is displayed on the web.

------------ Deploy zabbix ------------- Experiment Installation environment in the lamp environment:
Host Operating System IP address Main Software
Zabbix Server Centos 7 Zabbix Software Package
Linux Client Centos 7 Zabbix Software Package

Zabbix software package:
Baidu Network Disk link: https://pan.baidu.com/s/1MtfnTCgiP5tl2M6Jf0793Q password: mny1

# Disable the firewall on the zabbix server and client [[email protected] ~] # Systemctl stop firewalld. Service [[email protected] ~] # Setenforce 0 (must be off, otherwise zabbix will not be available)
-------- Install the lamp---1. Yum installation environment package
[[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
2. Configure HTTP
[[email protected] ~]# vi /etc/httpd/conf/httpd.conf

3. Set the PHP Time Zone
[[Email protected] ~] # Vi/etc/PHP. inidate. timezone = PRC // set China time zone = PRC

4. Open HTTP and database services
[[email protected] ~]# systemctl start httpd.service[[email protected] ~]# systemctl start mariadb.service[[email protected] ~]# netstat -ntap | egrep ‘(80|3306)‘

5. install and configure the database
[[email protected] ~]# mysql_secure_installation 

6. Enter the database to create a database for zabbix.
[[Email protected] ~] # Mysql-u root-pcreate database zabbix Character Set utf8 collate utf8_bin; # create a database for zabbix to grant all privileges on *. * To 'zabbix' @ '%' identified by 'admin123'; # Upgrade permissions. All databases and tables are operated by zabbix users. The password is admin123flush privileges. # refresh the password.

7. Test PHP
[[Email protected] ~] # Vi/var/www/html/index. php # create a file and test the basic PHP information. <? Phpphpinfo ();?> # Save and exit after writing. Enter the zabbix server address to test PHP.

8. Test whether PHP can connect to the database
[[Email protected] ~] # Vi/var/www/html/index. php # create a new test file and test whether the file can connect to the MySQL database. <? PHP $ link = mysql_connect ('192. 168.100.128 ', 'zabbix', 'admin123'); if ($ link) echo "

---------------- Deploy zabbix server ----------- 1. Yum installation environment package and zabbix sever
[[email protected] ~]# yum install php-bcmath php-mbstring -y
[[Email protected] ~] # Rpm-IVH http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm // automatically generates the yum source file, but the system must be accessible

[[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
2. Generate the zabbix Database
[[Email protected] ~] # Zcat/usr/share/doc/zabbix-server-mysql-4.0.0/create. SQL .gz | mysql-uzabbix-P zabbix // generate the database file, be sure not to enter the password as root.

3. modify the configuration file of zabbix Server
[[email protected]bbix ~]# vim /etc/zabbix/zabbix_server.conf 

4. Check whether the configuration file is correctly configured.
[[Email protected] ~] # Grep-n' ^ '[A-Z]/etc/zabbix/zabbix_server.conf 38: logfile =/var/log/zabbix/zabbix_server.log49: logfilesize = 072: pidfile =/var/run/zabbix/zabbix_server.pid82: socketdir =/var/run/zabbix101: dbname = zabbix117: dbuser = zabbix125: dbpassword = admin123 // modify row 347: snmptrapperfile =/var/log/SNMPTRAP. log465: timeout = 4507: alertscriptspath =/usr/lib/zabbix/alertscripts517: externalscripts =/usr/lib/zabbix/externalscripts553: logslowqueries = 3000
5. Modify Apache Time Zone
[[Email protected] ~] # Vim/etc/httpd/CONF. d/zabbix. conf // change the time zone php_value date. timezone Asia/Shanghai // to the Shanghai Time Zone

6. corrected Chinese garbled characters in charts
[[Email protected] ~] # Vim/usr/share/zabbix/include/defines. Inc. php // corrected the Chinese garbled characters in the chart: % S/graphfont/kaiti/g // to replace all fonts. Copy the corresponding font file from the Microsoft system to the/usr/share/zabbix/fonts directory. Note that the font name must correspond to the configuration file and be case sensitive.

7. Install and mount the zabbix Software Package

Zabbix software package:
Baidu Network Disk link: https://pan.baidu.com/s/1MtfnTCgiP5tl2M6Jf0793Q password: mny1

[[Email protected] ~] # Yum install lrzsz-y [[email protected] ~] # RZ # After installation, run the RZ command to upload files between Windows and Linux. The files are mounted to the current directory.
[[email protected] ~]# cp STKAITI.TTF /usr/share/zabbix/fonts/

8. Start various services
[[Email protected] ~] # Systemctl enable zabbix-server // set auto-start upon startup [email protected] ~] # Systemctl start zabbix-server [[email protected] ~] # Netstat-anpt | grep zabbix // listen to port 10051
PS: problems may occur here, such:

------------- Solve the local login failure problem (can be ignored )---------------------------

[[Email protected] ~] # Mysql-uroot-P // log on to the database as the root user: Select User, host from MySQL. user; // if the user name is occupied, the user cannot log on to the local computer and can log on remotely. + -------- + ------------- + | user | host | + -------- + ----------- + | zabbix | % | root | | Root |:: 1 | cacti | root | cacti | localhost | root | localhost | + -------- + ----------- + drop user ''@ localhost; drop user'' @ cacti; flush privileges;
Then restart zabbix. 9. Restart the HTTP service and log on to zabbix.
[[Email protected] ~] # Systemctl restart httpd. servicehttp: // // after installation, log on to the admin user name and password: zabbix

----------- Configure the proxy-that is, the controlled server-if the server needs to be monitored by itself, you also need to install -- zabbix-agent -- 1. Disable the Firewall
[[email protected] ~]# systemctl stop firewalld.service[[email protected] ~]# systemctl disable firewalld.service [[email protected] ~]# setenforce 0
2. Install the zabbix Yum Source
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
3. Install zabbix agent
[[email protected] ~]# yum install -y zabbix-agent
4. Modify zabbix agent Configuration
[[email protected] ~]# vim /etc/zabbix/zabbix_agentd.conf

[[Email protected] ~] # Grep-n' ^ '[A-Z]/etc/zabbix/zabbix_agentd.conf // modify the configuration as follows: 13: pidfile =/var/run/zabbix/zabbix_agentd.pid32: logfile =/var/log/zabbix/sources: logfilesize = 098: Server = serveractive = Hostname = test268: Include =/etc/zabbix/zabbix_agentd.d /*. conf

5. Enable zabbix agent
[[email protected] ~]# systemctl enable zabbix-agent.service[[email protected] ~]# systemctl restart zabbix-agent.service
[[Email protected] ~] # Netstat-anpt | grep 10050 // listening on port 10050

-------------- Add a host to be controlled-create a host on the Web Platform ---------

Configuration-host-create Host:

Host page configuration as needed
The template page needs to link the template and the corresponding template as needed
0 k

On the homepage, two errors are displayed. One is that the monitored side does not install the HTTP service, and the other is that the host cannot parse the client host name.

Problem analysis: the host name cannot be resolved when the host is pinged to the client. Solution: Add a record zabbix to/etc/hosts. after the server is saved, the problem is solved and there are no more alarm emails.
-------- Configure and test the mail alarm function --- configure --------- 1. Install mailx on the server and configure
[[email protected] ~]# yum install mailx -y
[[Email protected] ~] # Vim/etc/mail. RC // note that the client Authorization code must be enabled for third-party logon in NetEase mail ---- Add at the end of the file --- set [email protected] Set SMTP = smtp.qq.com // set [email protected] Set SMTP-auth -Password = third-party authorization code set SMTP-auth = Login

Third-party authorization code generation in QQ mail:

2. test normal mail sending
[[Email protected] ~] # Echo "Hello World" | mail-s "testmail" [email protected] // test whether the mail is normal

3. write an email script
[[email protected] ~]# cd /usr/lib/zabbix/alertscripts
[[Email protected] ~] # Vi mailx. Sh // write an email script
#!/bin/bash#send mailmessages=`echo $3 | tr ‘\r\n‘ ‘\n‘`subject=`echo $2 | tr ‘\r\n‘ ‘\n‘`echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mail.log 2>&1

4. Create and upgrade zabbix Permissions
[[email protected] ~]# touch /tmp/mail.log [[email protected] ~]# chown -R zabbix.zabbix  /tmp/mail.log [[email protected] ~]# chmod +x /usr/lib/zabbix/alertscripts/mail.sh[[email protected] ~]# chown -R zabbix.zabbix /usr/lib/zabbix/
5. Test the mail script.
[[Email protected] ~] #./Mail. Sh [email protected] "yunjisuan" "zabbix test" // test whether the email script works properly

Enterprise distributed monitoring zabbix deployment + installation troubleshooting local logon failures + test email alert

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.