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 deployment + email alarm

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

Share

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

Zabbix introduction

If you want to understand the running status of the server in real time and solve problems in time, the use of monitoring software is a good choice, and zabbix monitoring system stands out among many monitoring software.

Zabbix is an enterprise-level open source monitoring software based on web interface. Zabbix server needs LAMP environment or LNMP environment to provide distributed system monitoring and network monitoring functions. With host performance monitoring, network equipment performance monitoring, database performance monitoring, a variety of alarm methods, detailed reports, chart drawing and other functions. The monitoring objects can be Linux or Windows servers, routers, switches and other network devices. The monitoring and data collection functions of remote network servers are provided by means of SNMP, zabbix Agent, PING, port monitoring and so on.

Zabbix Monitoring Architecture:

In a production environment, zabbix is divided into three architectures according to external factors such as network environment and monitoring scale: server-client (direct connection), master-node-client (Node architecture) and server-proxy-client (proxy architecture), as shown in the following figure:

1. Server-client architecture: server-client architecture is the simplest architecture of zabbix. Without any agent, the monitoring machine and the monitored computer directly exchange data between zabbix server (monitoring server) and zabbix agent (agent: deployed on the monitored side to collect data). It is suitable for the monitoring environment where the network is simple and there are few devices. 2. Master-node-client architecture: master-node-client architecture is the most complex monitoring architecture of zabbix, which is suitable for large-scale environments with multiple devices and across networks and computer rooms. Each node is also a server, which can be connected to proxy or client directly under node. Node has its own configuration file and database, and all it needs to do is synchronize configuration information and monitoring data to master. When master goes down, node can guarantee the integrity of the architecture. 3. Server-proxy-client architecture: proxy is a bridge between server and client. Proxy itself does not have a front end, and it does not store data. It only temporarily stores the data sent by agentd, and then submits it to server. This architecture is often compared with the master-node-client architecture, and is generally suitable for the monitoring of medium-sized network architecture across computer rooms and networks. Zabbix role component Zabbix agent: responsible for deploying on the monitored host and transmitting the data of the monitored host to zabbix serverZabbix server: responsible for receiving information sent by agent, organizing configuration information, statistical configuration information and operation data and other Zabbix database: used to store all configuration information of zabbix, database of monitoring data Zabbix web: web interface of zabbix, management can manage zabbix configuration and view monitoring information of zabbix through zabbix's web interface Zabbix proxy can be deployed only on a single server: 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 the zabbix serverzabbix communication mode agent: monitor through a dedicated agent: communicate through a remote control protocol SNMP: communicate with the monitored object through the SNMP protocol, routers and switches support SNMP In fact, it is also a kind of agentIPMI: monitoring through IPMI interface, monitoring through IPMI hardware interface, voltage, temperature, fan, and power supply status JMX: monitoring JVM virtual machine distributed monitoring system through (java management extensions Java management extension): monitoring data is submitted to zabbix proxy and then submitted 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

Monitoring side: 192.168.136.168

Monitored end: 192.168.136.185

Install LAMPyum install-y\ httpd\ mariadb-server mariadb\ php\ php-mysql\ php-gd\ libjpeg*\ php-ldap\ php-odbc\ php-pear\ php-xml\ php-xmlrpc / etc/httpd/conf/httpd.confServerName www.benet.comDirectoryIndex index.html index.phpvi / etc/php.inidate.timezone = PRC / / set China time zone systemctl stop firewalld.servicesetenforce 0systemctl start httpd.servicesystemctl start mariadb.servicenetstat-ntap | egrep'(80 | 3306) 'mysql_secure_installationvi / var/www/html/index.php

Http://192.168.175.155/

Mysql-u root-p # sets up a database for zabbix and sets a user to manage it CREATE DATABASE zabbix character set utf8 collate utf8_bin;GRANT all privileges ON *. * TO 'zabbix'@'%' IDENTIFIED BY' admin123';flush privileges # write a test home page [root@localhost ~] # cd / var/www/html/ [root@localhost html] # vim index.php# to verify whether zabbix can connect to the database-solve the local login problem (negligible)-[root@localhost html] # mysql-u root-pEnter password: Welcome to the MariaDB monitor. Commands end with; or\ g.Your MariaDB connection id is 9Server version: 5.5.64-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)] > select user,host from mysql.user / / if you cannot log in locally due to the occupation of an available user name, you can log in remotely. +-+-- + | user | host | +-+-- + | zabbix |% | root | | 127.0.0.1 | | root |:: 1 | localhost | | root | localhost | | localhost.localdomain | +-+-- + 6 rows in set (0.01sec) drop user''@ localhost | Drop user'@ cacti;flush privileges

-start deploying zabbix Server- below

Yum install php-bcmath php-mbstring-yrpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm / / automatically generates yum source files Ensure that the system can access yum install zabbix-server-mysql zabbix-web-mysql-yzcat / usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql- uzabbix-p zabbix / / generate database files Note that the password should not be typed into root's grep-n'^'[amurz] / etc/zabbix/zabbix_server.conf 38:LogFile=/var/log/zabbix/zabbix_server.log 49:LogFileSize=072:PidFile=/var/run/zabbix/zabbix_server.pid82:SocketDir=/var/run/zabbix101:DBName=zabbix117:DBUser=zabbix125:DBPassword=admin123 / / modify the line 347:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log465:Timeout=4507:AlertScriptsPath=/usr/lib/zabbix/alertscripts517:ExternalScripts=/usr/lib/zabbix/externalscripts553: LogSlowQueries=3000vim / etc/httpd/conf.d/zabbix.conf / / modify time zone php_value date.timezone Asia/Shanghaivim / usr/share/zabbix/include/defines.inc.php / / correct the Chinese garbled in the chart:% s / graphfont/kaiti graphfont/kaiti / copy the corresponding font file from Microsoft to the / usr/share/zabbix/fonts directory. Note that the font name corresponds to the configuration file. And pay attention to the case cp STKAITI.TTF / usr/share/zabbix/fonts/systemctl enable zabbix-serversystemctl start zabbix-servernetstat-anpt | grep zabbix/ / listen on port 10051 systemctl restart httpd.service

Http://192.168.136.168/zabbix/ login user name after installation Admin password: zabbix

Set Chinese environment Administrator-Users- Click user-language Settings-configure Agent-that is, the controlled server-if the server also needs to be monitored by itself, it also needs to be installed-- zabbix-agent--rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpmyum install-y zabbix- Agentgrep-n'^'[amurz] / etc/zabbix/zabbix_agentd.conf13:PidFile=/var/run/zabbix/zabbix_agentd.pid32:LogFile=/var/log/zabbix/zabbix_agentd.log43:LogFileSize=098:Server=192.168.175.155139:ServerActive=192.168.175.155150:Hostname=test268:Include=/etc/zabbix/zabbix_agentd.d/*.confservice firewalld stopsetenforce 0systemctl enable zabbix-agent.servicesystemctl restart zabbix-agent.servicenetstat-anpt | grep zabbix/ / listening on port 10050- -add the controlled host-- do it on the WEB platform-- configure-host-create the host: the host page needs to link the template page according to the requirements Link the corresponding template 0K as needed

-configure email alarm function-configure on the server-- yum install mailxvi / etc/mail.rc / / Note: NetEase mailbox needs to open the client authorization code for third-party login-add set from=1960277503@qq.comset smtp=smtp.qq.comset smtp-auth-user=1960277503@qq.comset smtp-auth-password= mailbox password set smtp-auth=loginecho "hello world" at the end of the file. | mail | -s "testmail" 1960277503@qq.com / / Test normal cd / usr/lib/zabbix/alertscriptsvi mailx.sh / / write email script #! / bin/bash#send mailmessages= `echo $3 | tr'\ n'\ n' `subject= `echo $2 | tr'\ n'\ n' echo "${messages}" | mail-s "${subject}" $1 > / tmp/mailx.log 2 > & 1-touch / tmp/mailx.log chown- R zabbix.zabbix / tmp/mailx.log chmod + x / usr/lib/zabbix/alertscripts/mailx.shchown-R zabbix.zabbix / usr/lib/zabbix/./mailx.sh 13951868284@139.com "subject"content" / Test whether the outgoing email script works properly-configure on the server WEB-manage-"alarm Media Type -" create Media Type-name: Mail-Test Type Script name: mailx.sh script parameters: / / add the following three parameters {ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE} Administration-user-Click Admin- alarm Media: type: Mail-Test / / call the above script recipient: 13951868284@139.com other default-Save configuration-Action-create Action-Delete default label Modify the trigger condition name: Mailx condition A host group = Linux servers action-"configure default procedure duration 60 default recipient: {TRIGGER.STATUS}: {TRIGGER.NAME} default information: alarm host: {HOST.NAME} alarm IP: {HOST.IP} alarm time: {EVENT.DATE}-{EVENT.TIME} alarm level: {TRIGGER.SEVERITY} alarm information: {TRIGGER.NAME}: { ITEM.VALUE} event ID: {EVENT.ID} Operation details:-"Operation type: send message to user: Admin (Zabbix Administrator) send only to: Mail-Test / / must be configured or mail is not successfully sent 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} Operation details:-"Operation type: send a message to the user: Admin (Zabbix Administrator) send only to: Mail-Test / / must be configured or the message sent is not successful systemctl restart zabbix-serversystemctl restart zabbix-agent.service- the following is the test alarm- The relevant parameters can be simulated to exceed the threshold on the controlled host. Such as disk space. Then verify the sending and receiving of email. Systemctl stop zabbix-agent.service / / turn off the receiving of test alarm messages on the monitored host

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