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 installation and deployment and email alarm

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

Share

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

What this article shares with you is the implementation of zabbix installation and deployment and email alarm. I believe most people have not learned this skill. In order to let you learn, I have summarized the following contents. The following are the detailed steps for the installation and deployment of zabbix and zabbix mail alarms.

Experimental realization 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" / / Test whether the email script works properly-configure on the server WEB

Management-"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 defaults-Save configuration-actions-create actions-remove default tags 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

The above is the specific introduction of zabbix installation and deployment and mail alarm, the content is more comprehensive. Through this article, I hope you can learn to install and deploy zabbix and use zabbix to achieve email alarm.

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