zabbix3.0.4安装部署与SendEmail报警配置

MySQL:5.6.21

nginx:1.62

PHP:5.7

pcre:8.32

zabbix:3.0.4

LNMP安装步骤略过

# tar xvf zabbix-3.0.4.tar.gz

# cd zabbix-3.0.4

cat >> /etc/services <eof

zabbix-agent    10050/tcp                          #ZabbixAgent

zabbix-agent    10050/udp                          #Zabbix Agent

zabbix-trapper  10051/tcp                            #ZabbixTrapper

zabbix-trapper  10051/udp                            #Zabbix Trapper

eof

#  ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent  --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java

# make &;&; make install

# useradd zabbix

#mysql

#mysql>create database zabbix default charset utf8;

#mysql>GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix.com' WITH GRANT OPTION;

# mysql zabbix < database/mysql/schema.sql

# mysql zabbix < database/mysql/images.sql

# mysql zabbix < database/mysql/data.sql

# vim /usr/local/zabbix/etc/zabbix_server.conf

DBHost=192.168.9.35

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix.com

# cp ./misc/init.d/fedora/core/zabbix_* /etc/init.d/

# sed -i "aliyunzixun@xxx.com=/usr/aliyunzixun@xxx.com=/usr/local/aliyunzixun@xxx.com" `grep BASEDIR=/usr/local -rl /etc/init.d/ |grep zabbix_ `

# chmod 775 /etc/init.d/zabbix_*

# cp -rp ./frontends/php/* /data/www/zabbix/

# chown -R nginx.nginx /data/www/zabbix

#vim  /usr/local/zabbix/etc/zabbix_agentd.conf

UnsafeUserParameters=1

# cd /usr/local/nginx/conf/vhost

# vim zabbix.conf

server {

listen  8888;

server_name _;

index index.html index.htm index.php;

root /data/www/zabbix;

location ~ .*/.(php|php5)?$

{

#fastcgi_pass  unix:/tmp/php-cgi.sock;

fastcgi_pass  127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*/.(js|css)?$

{

expires 1h;

}

location / {

if (-f $request_filename/Home.html){

rewrite (.*) $1/Home.html break;

}

if (-f $request_filename/index.php){

rewrite (.*) $1/index.php;

}

if (!-f $request_filename){

rewrite (.*) /index.php;

}

}

access_log  /usr/local/nginx/logs/zabbix.com.log;

}

zabbix3.0.4安装部署与SendEmail报警配置

zabbix3.0.4安装部署与SendEmail报警配置

配置SendEmail报警

# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

# tar xvf sendEmail-v1.56.tar.gz

# cp sendEmail-v1.56/sendEmail /usr/local/bin/

# chmod 755 /usr/local/bin/sendEmail

# mkdir /usr/local/zabbix/alertscripts

# vim /usr/local/zabbix/etc/zabbix_server.conf

AlertScriptsPath=/usr/local/zabbix/alertscripts

# touch /tmp/Email.log

# chown zabbix:zabbix /tmp/Email.log

# vim /usr/local/z#abbix/alertscripts/SendEmail.sh

#!/bin/bash

# Filename:    SendEmail.sh

# Revision:    0.1

# Date:        2015/07/07

# Author:      Deniss

# Email:

# Website:    http://9935226.blog.51cto.com/

# Description: zabbix邮件告警脚本

# Notes:      使用sendEmail

# 脚本的日志文件

LOGFILE="/tmp/Email.log"

:>"$LOGFILE"

exec 1>"$LOGFILE"

exec 2>&;1

SMTP_server='smtp.sina.com'    # SMTP服务器,变量值需要自行修改

username='aliyunzixun@xxx.com'    # 用户名,变量值需要自行修改

password='sina123'            # 密码,变量值需要自行修改

from_email_address='aliyunzixun@xxx.com' # 发件人Email地址,变量值需要自行修改

to_email_address="$1"              # 收件人Email地址,zabbix传入的第一个参数

message_subject_utf8="$2"          # 邮件标题,zabbix传入的第二个参数

message_body_utf8="$3"              # 邮件内容,zabbix传入的第三个参数

# 转换邮件标题为GB2312,解决邮件标题含有中文,收到邮件显示乱码的问题。

message_subject_gb2312=`iconv -t GB2312 -f UTF-8 << EOF

$message_subject_utf8

EOF`

[ $? -eq 0 ] &;&; message_subject="$message_subject_gb2312" || message_subject="$message_subject_utf8"

# 转换邮件内容为GB2312,解决收到邮件内容乱码

message_body_gb2312=`iconv -t GB2312 -f UTF-8 << EOF

$message_body_utf8

EOF`

[ $? -eq 0 ] &;&; message_body="$message_body_gb2312" || message_body="$message_body_utf8"

# 发送邮件

sendEmail='/usr/local/bin/sendEmail'

set -x

$sendEmail -s "$SMTP_server" -xu "$username" -xp "$password" -f "$from_email_address" -t "$to_email_address" -u "$message_subject" -m "$message_body" -o message-content-type=text -o message-charset=g

b2312

# chown zabbix:zabbix /usr/local/zabbix/alertscripts/SendEmail.sh

# chmod +x /usr/local/zabbix/alertscripts/SendEmail.sh

#登陆web配置

zabbix3.0.4安装部署与SendEmail报警配置

zabbix3.0.4安装部署与SendEmail报警配置

zabbix3.0.4安装部署与SendEmail报警配置

zabbix3.0.4安装部署与SendEmail报警配置

发送邮件

# /usr/local/bin/sendEmail -f aliyunzixun@xxx.com -t aliyunzixun@xxx.com / 
-s smtp.163.com -u "我是邮件主题" -o message-content-type=html / 
-o message-charset=utf8 -xu aliyunzixun@xxx.com -xp 123456 -m "我是邮件内容"

123

#/usr/local/bin/sendEmail -f aliyunzixun@xxx.com -t aliyunzixun@xxx.com /-s smtp.163.com -u "我是邮件主题" -o message-content-type=html /-o message-charset=utf8 -xu aliyunzixun@xxx.com -xp 123456 -m "我是邮件内容"

命令说明:

/usr/local/bin/sendEmail 命令主程序 
-f aliyunzixun@xxx.com 发件人邮箱 
-s smtp.163.com 发件人邮箱的smtp服务器 
-u "我是邮件主题" 邮件的标题 
-o message-content-type=html 邮件内容的格式,html表示它是html格式 
-o message-charset=utf8 邮件内容编码 
-xu aliyunzixun@xxx.com 发件人邮箱的用户名 
-xp 123456 发件人邮箱密码 
-m "我是邮件内容" 邮件的具体内容

123456789

/usr/local/bin/sendEmail 命令主程序-f aliyunzixun@xxx.com发件人邮箱-s smtp.163.com 发件人邮箱的smtp服务器-u "我是邮件主题" 邮件的标题-o message-content-type=html 邮件内容的格式,html表示它是html格式-o message-charset=utf8邮件内容编码-xualiyunzixun@xxx.com发件人邮箱的用户名-xp 123456 发件人邮箱密码-m "我是邮件内容"邮件的具体内容

上一篇:Django 配置文件settings注解(含静态文件和上传文件配置)


下一篇:cookie 和session 的区别详解