The Zabbix of Linux monitoring system

Source: Internet
Author: User
Tags install php ibm db2 symlink

Zabbixzabbix introduction of Linux monitoring System

Zabbix is a network monitoring and management system developed by Zabbix Alexei Vladishev, based on the server-client architecture. can be used to monitor the status of various network services, servers, and network machines. Integrates the features of Catic and Nagios.

Use a variety of database-end such as MySQL, PostgreSQL, SQLite, Oracle or IBM DB2 to store data. The Server side is based on the C language, WEB management side frontend is based on PHP. Zabbix can be monitored in a variety of ways. You can only use simple Check to not install Client side, or SMTP or HTTP based ... Various protocols are monitored.

After installing the Zabbix agent in Windows on clients such as UNIX, you can monitor various states such as CPU Load, network usage, hard disk capacity, and so on. And even if the Agent is not installed in the monitoring object, Zabbix can also monitor the target via SNMP, TCP, ICMP, IPMI, SSH, Telnet.

Zabbix principle

The approximate process for a monitoring system to run is this:
The Zabbix agent needs to be installed on the monitored host, which collects the data periodically and sends it to the Zabbix server side, Zabbix server stores the data in the database, Zabbix the web to show and draw on the front end based on the data. Here the agent collects data into both active and passive modes:
Active: The agent requests the server to get a list of active monitoring items and proactively submits the data that needs to be detected in the monitoring item to Server/proxy
Passive: The server requests data from the agent for the monitored items, and the agent returns the data.

Zabbix components

The Zabbix consists of the following component parts:
1, Zabbix Server: Responsible for receiving agent sent the report information of the core components, all configuration, statistics and operational data are organized by its organization;

2, Database Storage: Dedicated to store all configuration information, as well as the data collected by Zabbix;

3, the Web Interface:zabbix GUI interface, usually with the server running on the same host;

4, Proxy: Optional components, commonly used in distributed monitoring environment, the agent server collects the monitoring data of the monitoring side and sends it to the server side uniformly;

5, Agent: Deployed on the monitored host, responsible for collecting local data and to the server side or proxy side;

ZABBIX schematic diagram

Test environment
role IP Address
Zabbix-server 192.168.58.149
Zabbix-client 192.168.58.157
Zabbix Installation

First build the lamp environment, I choose to use the Yum Warehouse installation.

[[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

After installing the lamp schema, modify the httpd.conf configuration file.

[[email protected] ~]# vim /etc/httpd/conf/httpd.conf <IfModule dir_module>    DirectoryIndex index.html index.php</IfModule>

Modify the PHP configuration file php.ini Modify the time zone, or you will get an error.

[[email protected] ~]# vim /etc/php.ini [Date]; Defines the default timezone used by the date functions; http://php.net/date.timezonedate.timezone = PRC  #修改为中国时区、

Turn off firewall and selinux functionality.

[[email protected] ~]# systemctl stop firewalld.service[[email protected] ~]# setenforce 0

Turn on the httpd and MARIADB services for configuration.

[[email protected] ~]# systemctl start httpd.service[[email protected] ~]# systemctl start mariadb.service[[email protected] ~]# netstat -ntap | egrep ‘(80|3306)‘tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      68787/mysqld        tcp6       0      0 :::80                   :::*                    LISTEN      67276/httpd#可以看到80和3306端口已经开启

Here are some security settings for MARIADB.

[[email protected] ~]# mysql_secure_installation#可以根据自己情况选择对应的设置

Write a PHP test page and test it.

[[email protected] ~]# vim /var/www/html/index.php<?phpphpinfo();?>

Access to http://192.168.58.149/index.php, easy access to the following interface to illustrate the success of lamp build.

Access to the database created to Zabbix stored data database, has been given the relevant permissions.

[[email protected] ~]# mysql -u root -pEnter password: Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 6Server version: 5.5.60-MariaDB MariaDB ServerCopyright (c) 2000, 2018, 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)#创建一个叫zabbix的数据库,默认字符集为utf-8MariaDB [(none)]> GRANT all privileges ON *.* TO ‘zabbix‘@‘%‘ IDENTIFIED BY ‘admin123‘;Query OK, 0 rows affected (0.00 sec)#赋予权限MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)#刷新权限

Write the Database test login page below.

[[email protected] ~]# vim /var/www/html/index.php<?php$link=mysql_connect(‘192.168.58.149‘,‘zabbix‘,‘admin123‘);if($link) echo "

Again to access the http://192.168.58.149/index.php, you can see the fail, here the reason is that there is an empty user presence in the database.

[[email protected] ~]# mysql-u root-penter password:mariadb [(None)]> Select User,host from mysql.user;+------- -+-------------------------+| user | Host |+--------+-------------------------+| Zabbix | % || Root | 127.0.0.1 | | Root | :: 1 | | | localhost | | Root | localhost | | | promote.cache-dns.local | | Root | Promote.cache-dns.local |+--------+-------------------------+7 rows in Set (0.00 sec) #可以看到有两个空用户, we remove these two empty users. MariaDB [(None)]> drop user ' @localhost; Query OK, 0 rows affected (0.01 sec) MariaDB [(None)]> drop user ' @ ' promote.cache-dns.local '; Query OK, 0 rows Affected (0.00 sec) MariaDB [(None)]> Select User,host from mysql.user;+--------+--------------------- ----+| user | Host |+--------+-------------------------+| Zabbix | % || Root | 127.0.0.1 | | Root | :: 1 || Root | localhost | | Root | Promote.cache-dns.local |+--------+-------------------------+5 rows in Set (0.00 sec)

Then we will visit http://192.168.58.149/index.php and we can see the success of the visit.

Install Zabbix Server below and install the dependent packages first.

[[email protected] ~]# yum install php-bcmath php-mbstring -y

Download Zabbix's 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[[email protected] ~]# ls /etc/yum.repos.d/CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo zabbix.repo#可以看到自动生成了zabbix.repo文件。

Install Zabbix-server related packages.

[[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql -y

Generates a Zabbix database file in the database.

[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -p zabbix Enter password: #注意这里是使用zabbix用户和密码登录的。

We look at the Zabbix-server configuration file and use regular expressions to filter it.

[[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=zabbix356:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log474:Timeout=4517:AlertScriptsPath=/usr/lib/zabbix/alertscripts528:ExternalScripts=/usr/lib/zabbix/externalscripts564:LogSlowQueries=3000

Here we just insert a line of dbpassword=admin123.

[[email protected] ~]# sed -i ‘127aDBPassword=admin123‘ /etc/zabbix/zabbix_server.conf [[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=zabbix128:DBPassword=admin123357:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log475:Timeout=4518:AlertScriptsPath=/usr/lib/zabbix/alertscripts529:ExternalScripts=/usr/lib/zabbix/externalscripts565:LogSlowQueries=3000

Change the time zone in the Zabbix user's zabbix.conf in the httpd service to Asia/shanghai.

[[email protected] ~]# vim /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 always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai </IfModule>

The following is mainly to solve the installation of Zabbix, the Web page display will be garbled, first the configuration file fonts are changed to Kaiti.

vim /usr/share/zabbix/include/defines.inc.phpdefine(‘ZBX_FONT_NAME‘, ‘graphfont‘);#这是默认字体[[email protected] ~]# sed -i ‘s/graphfont/kaiti/g‘ /usr/share/zabbix/include/defines.inc.php [[email protected] ~]# sed -n ‘/graphfont/p‘ /usr/share/zabbix/include/defines.inc.php #可以看到所有的都替换为了kaiti[[email protected] ~]# cp STKAITI.TTF /usr/share/zabbix/fonts/#将字体文件复制到zabbix的字体目录中

Start the Zabbix-server service.

[[email protected] ~]# systemctl enable zabbix-serverCreated symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.[[email protected] ~]# systemctl start zabbix-server[[email protected] ~]# netstat -anpt | grep zabbix tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 93906/zabbi_server tcp6 0 0 :::10051 :::* LISTEN 93906/zabbi#可以看到zabbix服务已经开启,相对应的端口已经打开

Restart the httpd service.

[[email protected] ~]# systemctl restart httpd.service

Visit http://192.168.58.149/zabbix/






After the server is configured, the client is configured below, which is the client side that needs to be monitored. First, configure 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[[email protected] ~]# yum install -y zabbix-agent

Modify the zabbix_agentd.conf configuration file below

[[email protected] ~]# grep -n ‘^‘[a-Z] /etc/zabbix/zabbix_agentd.conf13:PidFile=/var/run/zabbix/zabbix_agentd.pid32:LogFile=/var/log/zabbix/zabbix_agentd.log43:LogFileSize=098:Server=127.0.0.1139:ServerActive=127.0.0.1150:Hostname=Zabbix server268:Include=/etc/zabbix/zabbix_agentd.d/*.conf

Mainly modify the following lines

Server=192.168.58.149ServerActive=192.168.58.149Hostname=Zabbix1 #这个随意更改

Turn off firewall and SELinux features

[[email protected] ~]# systemctl stop firewalld.service[[email protected] ~]# setenforce 0

Enable the Zabbix-agent feature.

[[email protected] ~]# systemctl enable zabbix-agent.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.[[email protected] ~]# systemctl restart zabbix-agent.service[[email protected] ~]# netstat -anpt | grep zabbixtcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4936/zabbix_agentd tcp6 0 0 :::10050 :::* LISTEN 4936/zabbix_agentd #可以看到监听端口10050已经开启

The following need to add the monitored host on the Zabbix detection Web page.




Finally, we test and close the SSH service of the monitored host to see if there will be an alarm.

[[email protected] ~]# systemctl stop sshd.service

The Zabbix of Linux monitoring system

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.