Compile and install zabbix3.4 and implement mail alarm

Source: Internet
Author: User

Environment Preparation:
Lnmp

Download zabbix3.4
Wget-c http://cdn-us.filecluster.com/Zabbix/zabbix-3.4.11.tar.gz
TAR-XF zabbix-3.4.11.tar.gz

Create a Zabbix database
Mysql-uroot-p
Mysql> CREATE database Zabbix character set UTF8 collate utf8_bin;
Mysql> Grant all privileges the zabbix.* to [e-mail protected] identified by ' Zabbix ';
Mysql-uroot-pzabbix Zabbix </root/zabbix-3.4.11/database/mysql/schema.sql
Mysql-uroot-pzabbix Zabbix </root/zabbix-3.4.11/database/mysql/images.sql
Mysql-uroot-pzabbix Zabbix </root/zabbix-3.4.11/database/mysql/data.sql

New Zabbix users and user groups
Groupadd Zabbix
Useradd-g zabbix-s/sbin/nologin Zabbix

Install dependent packages
Yum-y Install net-snmp-devel libssh2 libssh2-devel curl-devel libevent libevent-devel

Installing the Zabbix Server Agent
cd/root/zabbix-3.4.11
./configure--prefix=/usr/local/zabbix--sysconfdir=/etc/zabbix--enable-server--enable-agent--with-ssh2-- With-openssl--with-mysql=/usr/local/mysql/bin/mysql_config--with-net-snmp--with-libcurl--with-libxml2
Make install

Modify the Zabbix default log file location
mkdir/var/log/zabbix/
Chown-r Zabbix.zabbix/var/log/zabbix

Modifying a configuration file
Vim/etc/zabbix/zabbix_server.conf

1 dbname=Zabbix2 dbuser=Zabbix3 dbpassword=Zabbix4 Logfile=/var/log/zabbix/zabbix_server.log

Vim/etc/zabbix/zabbix_agentd.conf

1 logfile=/var/log/zabbix/zabbix_agentd.log2 server=192.168. 121.11
3 hostname= Zabbix Server

Set Startup scripts

cp/usr/local/zabbix/sbin/*/usr/local/sbin/
Cp/usr/local/mysql/lib/libmysqlclient.so/usr/lib64
Cp/usr/local/mysql/lib/libmariadb.so.3/usr/lib64
cp/root/zabbix-3.4.11/misc/init.d/fedora/core5/*/etc/init.d/
Chkconfig--add Zabbix_agentd
Chkconfig--add Zabbix_server
Chkconfig Zabbix_agentd on
Chkconfig Zabbix_server on
Service Zabbix_server Start
Service Zabbix_agentd Start

Create a Zabbix Site Directory
Mkdir/usr/local/nginx/html/zabbix
cp/root/zabbix-3.4.11/frontends/php/*/usr/local/nginx/html/zabbix-a
Chown-r Nginx:nginx/usr/local/nginx/html/zabbix

Vim/usr/local/etc/php.ini

1 max_input_time=2 post_max_size = 32M34 Data_ Zone=rpc

Zabbix Graphics Support Chinese
vim/usr/local/nginx/html/zabbix/include/defines.inc.php to modify two places Dejavusans=simkai
Upload Simkai.ttf to the/usr/local/nginx/html/zabbix/fonts/directory

http://192.168.121.11/zabbix/setup.php

Open firewall port

Firewall-cmd--zone=public--permanent--add-port=10050-10051/tcp
Firewall-cmd--zone=public--permanent--add-port=10050-10051/udp
Firewall-cmd--reload

Set up Zabbix Mail alerts
Close SendMail or Postfix
Yum Remove SendMail
Yum Remove Postfix
Installing MAILX
Yum Install Mailx dos2unix-y
Vim/etc/mail.rc

1 set from="[email protected]"2 set SMTP=SMTP. 163 . com 3 Set [email protected]163. com4 set smtp-auth-password=passwd  5 Set smtp-auth=login

Test mail settings are healthy
echo "Zabbix test Mail" |mail-s "Zabbix" [email protected]

Management--Alarm media type--Create alarm media Type--select script Type--fill in the script name emai_vps.sh
Add three script parameters {ALERT. SENDTO} {ALERT. SUBJECT} {ALERT. MESSAGE}
User--Alarm Media--Select script
Action--Create action--fill in the action name
Operation:

1 {TRIGGER. STATUS}, server: {Hostname1}:{trigger.name} failure occurred! 2 Alarm Host: {HOSTNAME1} 3 Alarm time: {EVENT. DATE} {EVENT. TIME}4  alarm level: {TRIGGER. SEVERITY}5  warning message: {trigger.name}6  Alarm item: {TRIGGER. KEY1}7  problem details: {item.name}:{item. VALUE}8 Event Id:{event.id}

Restore operation:

1       {TRIGGER. STATUS}: Server: {HOSTNAME1}: {Trigger.name} failure recovery! 2        Alarm host: {hostname1}3        alarm time: {EVENT. DATE} {EVENT. Time}4        Alarm level: {TRIGGER. Severity}5        Alarm message: {trigger.name}6        alarm item: {TRIGGER. Key1}7        Current status: {TRIGGER. Status}:{item. Value1}8        Event Id:{event.id}

Confirm Action:

 1   {TRIGGER. STATUS}: admin {USER. FULLNAME} server: {Hostname1}:{trigger.name} failure confirmation!  2   admin {USER. FULLNAME} in {ACK. DATE} {ACK. Time} {ACK. Message} to confirm the failure information.  3   alarm host: {HOSTNAME1}  4   alarm time: {EVENT. Date}{event. TIME}  5   alarm level: {TRIGGER. SEVERITY}  6   alarm message: {trigger.name}  Span style= "COLOR: #008080" >7   alarm item: {TRIGGER. KEY1}  8   question details: {Item.name}:{item. VALUE}  9  event Id:{event.id} 

Add Zabbix server mail send script
vi/etc/zabbix/zabbix_server.conf modify alertscriptspath=/etc/zabbix/alertscripts
mkdir/ Etc/zabbix/alertscripts
Chown zabbix.zabbix/etc/zabbix/alertscripts
Vim emai_vps.sh

1 #!/bin/bash2file=/tmp/zabbix_mail.txt3echo  "$ $" > $file4 dos2unix-k $file  #转码中文 5  "$ $" $1 < $file

chmod u+x email_vps.sh
Chown Zabbix.zabbix email_vps.sh

Compile and install zabbix3.4 and implement mail alarm

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.