Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix monitoring-deployment, monitoring and email alarm mechanism (fuck! )

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Introduction to zabbix

Zabbix is an enterprise-level open source solution based on WEB interface that provides distributed system monitoring and network monitoring capabilities.

Zabbix can monitor various network parameters to ensure the safe operation of the server system, and provides a flexible notification mechanism to enable system administrators to quickly locate / solve various problems.

Zabbix consists of two parts, zabbix server and optional component zabbix agent.

Zabbix server can provide remote server / network status monitoring, data collection and other functions through SNMP,zabbix agent,ping, port monitoring and other methods. It can run on platforms such as Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X.

Zabbix role components

Zabbix agent: responsible for deploying on the monitored host and transmitting the data of the monitored host to zabbix server

Zabbix server: responsible for receiving information sent by agent, organizing configuration information, statistical configuration information and operation data, etc.

Zabbix database: database for storing all configuration information of zabbix and monitoring data

Zabbix web: zabbix's web interface. Management can manage zabbix configuration and view zabbix monitoring information through zabbix's web interface, which can be deployed on a single server.

Zabbix proxy: used in a distributed environment, zabbix proxy manages the collection of information in this area on behalf of the server, and finally sends it to zabbix server

Zabbix communication mode

Agent: monitoring through a dedicated agent

Ssh/Telnet: communicate through remote control protocol

SNMP: communicates with monitored objects through SNMP protocol. Routers and switches support SNMP, which is actually a kind of agent.

IPMI: monitor through IPMI interface, monitor voltage, temperature, fan, and power supply status through IPMI hardware interface

JMX: monitor JVM virtual machines through (java management extensions Java Management extension) ~

Distributed monitoring system: monitoring data is submitted to zabbix proxy and then to zabbix server

Zabbix working mode active mode: the agent side actively collects information and sends it to the server side tool is the zabbix_sender passive mode: the server side active pull information tool is the zabbix_get experimental environment detection side server 192.168.13.128 detected side agent 192.168.13.1301 Install lamp schema on master [root@server ~] # systemctl stop firewalld.service # # close firewall [root@server ~] # systemctl disable firewalld.service [root@server ~] # setenforce 0firewall # install lamp schema # # [root@server ~] # yum install-y\ httpd\ mariadb-server mariadb\ php\ php-mysql\ # associated database php-gd\ libjpeg*\ php-ldap\ php-odbc\ php-pear\ php-xml\ php-xmlrpc\ Php-mhash [root@server ~] # vim / etc/httpd/conf/httpd.conf 95 ServerName www.yun.com:80 # Line 95 Delete comments, domain customization DirectoryIndex index.html index.php # 164line, add home page support class type index.php [root @ server ~] # vim / etc/php.ini 878 date.timezone = PRC # 878 line, put the previous template of Number deletion Add China time zone PRC [root@server ~] # systemctl start httpd.service # # enable the service [root@server ~] # systemctl start mariadb.service [root@server ~] # netstat-natp | egrep'(3306 | 80)'# View the port number tcp 00 0.0.0.0 systemctl start httpd.service 3306 0.0.0.0 * LISTEN 5087/mysqld tcp6 0 0:: 80: * LISTEN 4807/httpd [root@server ~] # mysql_secure_installation # # initialize the database Enter current password for root (enter for none): # enter Set root password directly here? [industry] y # set password New password: # abc123Re-enter new password: # confirm input: abc123Password updated fulfilling remove anonymous users? Do you want to delete anonymous users and choose not to delete Disallow root login remotely? [YPop] y # is it possible to connect to Remove test database and access to it remotely? Do you want to delete the test database Reload privilege tables now? [YBO] y # whether to reload... Success! [root@server ~] # mysql-u root-p # # Log in to the database MariaDB [(none)] > CREATE DATABASE zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.00 sec) # # create a zabbix database, and set it to utf8 format, and convert the strings in it to binary MariaDB [(none)] > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | test | | zabbix | +-+ 5 rows in set (0.00 sec) MariaDB [(none)] > GRANT all privileges ON *. * TO 'zabbix'@'%' IDENTIFIED BY' admin123' Query OK, 0 rows affected (0.01 sec) # leave all databases and tables to zabbix users to manage, and set the password to admin123MariaDB [(none)] > flush privileges # Refresh Query OK, 0 rows affected (0.00 sec) MariaDB [(none)] > quit # exit database Bye// test php basic information / / [root@server ~] # cd / var/www/html/ [root@server html] # ls [root@server html] # vim index.php// access web page with browser / /

/ / Test database connection / / [root@localhost html] # vim index.php

2. On the above page, if the actual fail (solution) [root@server html] # mysql-u zabbix-pEnter password: # cannot log in to the database by entering admin123 at this time, it means that a user occupies ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES) `first use root users to log in to the database` [root@server html] # mysql-u root-pMariaDB [(none)] > select user,host from mysql.user # # View user table +-+ | user | host | +-+-+ | zabbix |% | | root | 127.0.0.1 | | root |:: 1 | | server | | localhost | | root | localhost | +-+ -+ MariaDB [(none)] > drop user'@ localhost # # deleting empty user MariaDB [(none)] > drop user''@ server; # # deleting empty user MariaDB [(none)] > select user,host from mysql.user +-+-+ | user | host | +-+-+ | zabbix |% | root | 127.0.0.1 | | root |: 1 | | root | localhost | +-+-+ 4 rows in set (0.00 sec) MariaDB [(none) ] > quitBye## refreshes the page again at this time and the success will be displayed! Successfully logged in 3 Install and deploy zabbix-server [root@server html] # yum install php-bcmath php-mbstring-y [root@server html] # rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm## on server install Zabix source [root@server html] # cd / etc/yum.repos.d/ [root@server yum.repos.d] # cat zabbix.repo # # this is The source of the downloaded zabbix [zabbix] name=Zabbix Official Repository-$basearchbaseurl= http://repo.zabbix.com/zabbix/3.5/rhel/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-non-supported]name=Zabbix Official Repository non-supported-$basearchbaseurl= http://repo.zabbix.com/non-supported/rhel/7/$basearch/enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXgpgcheck=1[root@server yum.repos. D] # yum install zabbix-server-mysql zabbix-web-mysql-y # install Zabix [root @ server yum.repos.d] # zcat / usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql- u zabbix- p zabbix## generates a data file in the zabbix database [root@server yum.repos.d] # vim / etc/zabbix/zabbix_server.conf # # modify zabbix configuration file 125Root # # add Add zabbix database password [root@server yum.repos.d] # vim / etc/httpd/conf.d/zabbix.conf 20 php_value date.timezone Asia/Shanghai # # change to China time zone [root@server yum.repos.d] # vim / usr/share/zabbix/include/defines.inc.php # modify Chinese garbled # replace in last line mode:% s / graphfont/ Kaiti/g [root@server yum.repos.d] # cd / usr/share/zabbix/fonts/ # # upload stkaiti.ttf fonts [root@server fonts] # rz-E [root@server fonts] # lsgraphfont.ttf stkaiti.ttf [root@server fonts] # systemctl start zabbix-server.service # # enable zabbix service [root@server fonts] # systemctl enable zabbix-server.service [root@server fonts] # netstat-antp | grep zabbix (port) 10051) tcp 00 0.0.0.0 systemctl restart httpd.service 10051 0.0.0.0 root@server fonts * LISTEN 43984/zabbix_server tcp6 00: 10051: * LISTEN 43984/zabbix_server [root@server fonts] # systemctl restart httpd.service # # restart httpd service 4 Install zabbix on web

Click on the avatar in the upper right corner, select Chinese (zh_CN) simplified Chinese in the Language language bar, and click Update to update.

The configuration of the monitoring side is complete. 5 Configure agent proxy [root@agent ~] # systemctl stop firewalld.service [root@agent ~] # systemctl disable firewalld.service [root@agent ~] # setenforce 0 [root@agent ~] # rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm## install yum source [root@agent ~] # yum install zabbix-agent-y # # installation agent [root @ agent ~] # vim / etc/zabbix/zabbix_agentd.conf # # modify configuration file 98 Server=192.168.13.128 # # specify monitor server address 139 ServerActive=192.168.13.128 # # specify monitor server address 150 Hostname=test # # name [root@agent ~] # systemctl start zabbix-agent.service # # enable service [root@agent ~] # systemctl enable zabbix-agent.service [root@agent ~] # netstat-natp | grep zabbix ( Agent port number 10050) tcp 00 0.0.0.0 LISTEN 41189/zabbix_agentd 10050 0.0.0.0 LISTEN 41189/zabbix_agentd tcp6 00: 10050:: * LISTEN 41189/zabbix_agentd 6 Add the monitored agent side to the web side step 1: find the host option under the configuration, and click create Host

Step 2: enter the appropriate content in the host configuration interface, and then click the template

Step 3: select the template links for HTTP and SSH in the template, click add in the prompt, and then click the blue add icon

Step 4: you can see the monitoring problems on the monitoring dashboard

seven, Configure email alarm function-configure [root@server ~] # yum install mailx-y # # install mailx software [root@server] # vim / etc/mail.rc # # modify configuration file # # add set from=706858376@qq.comset smtp=smtp.qq.comset smtp-auth-user=706858376@qq.comset smtp-auth-password= authorization code on the last line # # here is the third party login authorization code set smtp-auth=login [root] of your mailbox @ server ~] # echo "hello world" | mail-s "testmail" 706858376@qq.com # # send email

eight, Write an email script [root@server ~] # cd / usr/lib/zabbix/alertscripts/ # # switch to [root@server alertscripts] # vim mailx.sh # # Edit the send email script #! / bin/bash#send mailmessages= `echo $3 | tr'\ n'\ n' `subject= `echo $2 | tr'\ r\ n' '`echo "${messages}" | mail-s "${subject}" $1 > > / tmp/ Mailx.log 2 > & 1 [root@server alertscripts] # touch / tmp/mailx.log # # create Log [root@server alertscripts] # chown-R zabbix.zabbix / tmp/mailx.log # # Authorization Master Group [root@server alertscripts] # chmod + x / usr/lib/zabbix/alertscripts/mailx.sh # # execute permissions [root@server alertscripts] # chown-R zabbix.zabbix / usr/lib/zabbix/ # # Authorization Master Group [root@server alertscripts] #. / mailx.sh 706858376@qq.com "yun"heihei"

9. Configure alarm media on the web. Step 1: select Management above, find the alarm media type, click create Media Type in the upper right corner of the page, and enter relevant information in the interface.

Step 2: three detection services will be displayed in the option. If the service is disabled, an alarm will be triggered. Finally, click the blue add icon below to generate a new alarm type.

Step 3: find the user interface in the configuration and click Admin user

Step 4: click add in the user's alarm media, enter the corresponding media information, and finally click add

Step 5: don't forget to click Update after adding media

Step 6: delete the original template in the action, redefine it, and click create action in the upper right corner.

Step 7: do the following in the operation, click New below, do the add operation, and finally click Update

Template: default procedure duration 60 default recipient: {TRIGGER.STATUS}: {TRIGGER.NAME} default message: alarm host: {HOST.NAME} alarm IP: {HOST.IP} alarm time: {EVENT.DATE}-{EVENT.TIME} alarm level: {TRIGGER.SEVERITY} alarm message: {TRIGGER.NAME}: {ITEM.VALUE} event ID: {EVENT.ID} step 8: configuration in recovery operation

Template: recovery operation: {TRIGGER.STATUS}: {TRIGGER.NAME} recovery information: recovery host: {HOST.NAME} recovery IP: {HOST.IP} recovery time: {EVENT.DATE}-{EVENT.TIME} recovery level: {TRIGGER.SEVERITY} recovery information: {TRIGGER.NAME}: {ITEM.VALUE} recovery ID: {EVENT.ID} step 9: click on the blue flag to add, and continuous monitoring will be carried out at this time.

[root@agent yum.repos.d] # systemctl stop sshd # # disable the ssh service on the monitored side

[root@agent yum.repos.d] # systemctl start sshd # # enable the ssh service on the monitored side

Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report