#启动邮箱服务
systemctl start postfix.service
#配置用户的邮箱发送邮件
vim /etc/mail.rc
set from="xxx@xxx.com"
set smtp="smtps://smtp.exmail.qq.com:465"
set smtp-auth-user="xxx@xxx.com"
set smtp-auth-password="xxxxxx"
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb
#测试发送邮件
[root@VM_centos ~]# echo "messages" | mail -v -s "subject" yxxx@qq.com
Resolving host smtp.exmail.qq.com . . . done.
Connecting to 163.177.90.125:465 . . . connected.
Error in certificate: Peer's certificate issuer is not recognized.
Comparing DNS name: "pop.qq.com"
Comparing DNS name: "ex.qq.com"
Comparing DNS name: "imap.exmail.qq.com"
Comparing DNS name: "rtx.exmail.qq.com"
Comparing DNS name: "smtp.exmail.qq.com"
SSL parameters: cipher=AES-128, keysize=128, secretkeysize=128,
issuer=CN=GeoTrust RSA CA 2018,OU=www.digicert.com,O=DigiCert Inc,C=US
subject=CN=pop.qq.com,OU=R&D,O=Shenzhen Tencent Computer Systems Company Limited,L=Shenzhen,ST=Gu
220 smtp.qq.com Esmtp QQ Mail Server
...
>>> QUIT
221 Bye
#解决证书解析报错
#手动的获取QQ 邮箱的证书保存到本地指定的目录里以备调用和验证
[root@VM_centos ~]# cd /etc/pki/nssdb/
[root@VM_centos nssdb]# ls
cert8.db cert9.db key3.db key4.db pkcs11.txt secmod.db
[root@VM_centos nssdb]# echo -n | openssl s_client -connect smtp.exmail.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >qq.crt
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify return:1
depth=0 C = CN, ST = Guangdong, L = Shenzhen, O = Shenzhen Tencent Computer Systems Company Limited, OU = R&D, CN = pop.qq.com
verify return:1
DONE
[root@VM_centos nssdb]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb -i qq.crt
[root@VM_centos nssdb]# certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb -i qq.crt
[root@VM_centos nssdb]# certutil -L -d /etc/pki/nssdb
#进入邮箱 SSL 证书存放目录,为了信任证书的标记操作
[root@VM_centos nssdb]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
Notice: Trust flag u is set automatically if the private key is present.
#解决发送是附件
#只要把行尾^M去掉,然后发送的话就不会是附件的形式了
[root@VM_centos nssdb]# yum -y install dos2unix.x86_64
[root@VM_centos nssdb]# vim /usr/lib/zabbix/alertscripts/sendmail.sh
#!/bin/bash
TMP_FILE=/usr/lib/zabbix/alertscripts/tmp_messages.txt
 
echo $3 | tr '\r\n' '\n' > ${TMP_FILE} #把^M替换为\n
# dos2unix ${TMP_FILE} #解决发送的邮件内容变成附件的问题 未解决
subject=$2
mail -s "${subject}" $1 >>/var/log/sendmail.log 2>&1 <${TMP_FILE}
 
#注意权限是chown zabbix.zabbix
#zabbix 管理---->报警媒介类型
#查看zabbix脚本位置
[root@VM_centos alertscripts]# grep alertscripts /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts
 

zabbix邮件脚本报警的更多相关文章

  1. zabbix4.2配置邮件+脚本报警:以QQ邮箱为例

    一.邮箱配置:开启smtp服务和授权 开启smtp选项后,系统会生成一个授权,你需要记住这个授权码,后面需要写入配置文件. 二.配置管理mailx: (1)安装mailx:[root@zabbix-s ...

  2. zabbix配置报警媒介-用户-动作-邮件脚本触发mailx邮件报警

    2018-09-16更新,新版本zabbix不需要使用脚本发送邮件,在zabbix web界面直接配置就可以 配置邮件参数,测试发送邮件 确认安装相关服务,centos7默认安装 [root@VM_1 ...

  3. 通过脚本发送zabbix邮件报警

    zabbix原生的报警媒介类型中,邮件报警是我们常用的方式.当我们在CentOS6上面安装zabbix3.0并配置邮件报警的时候,在邮件配置正确的前提下,不管触发器如何触发,邮件总是发送不出去,但是在 ...

  4. centos7之zabbix邮件报警(短信报警)

    前言 前面我们介绍了zabbix的基本linux和window及SNMP流量的简单监控,我们知道作为运维人员,需要7x24小时待命,但是我们不可能时时刻刻都坐在电脑旁边查看监控上的各个主机状态,所以我 ...

  5. Zabbix邮件报警配置

    一.安装sendmail或者postfix yum install sendmail #安装 service sendmail start #启动 chkconfig sendmail on #设置开 ...

  6. zabbix 邮件报警

    一.设置sendmail 安装sendmail yum install -y sendmail systemctl start sendmail.service 配置 cd  /usr/lib/zab ...

  7. Zabbix 邮件报警示例

     Zabbix 邮件报警示例: 1.编辑 mail.rc 文件添加默认的邮箱配置 # vi /etc/mail.rc set from=1234567@qq.com set smtp=smtp.qq. ...

  8. zabbix*邮件报警 *用户参数User parameters *定义key值 *Agentd主动模式与被动模式

    邮件报警 #下载安装邮件报警系统wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz yum - ...

  9. zabbix 邮件报警(五)

    一.sendEmail配置zabbix邮件报警 1.下载sendEmail: wget http://caspian.dotconf.net/menu/Software/SendEmail/sendE ...

随机推荐

  1. web自动化环境搭建(python+selenium+webdriver)

    本文档以谷歌浏览器为例,故自动化测试环境为下: 自动化工具为:selenium+webdriver 脚本语言为:Python3.X 浏览器:Chrome 系统环境:Win10 编译工具:Pycharm ...

  2. DVWA全级别之File Upload(文件上传)

    File Upload File Upload,即文件上传漏洞,通常是由于对上传文件的类型.内容没有进行严格的过滤.检查,使得攻击者可以通过上传木马获取服务器的webshell权限,因此文件上传漏洞带 ...

  3. 题解【SP8002】HORRIBLE - Horrible Queries

    题面 题解 这是一道线段树的模板题. 题目需要我们维护一个支持区间修改.区间查询的一个数据结构,很容易想到线段树. 然后发现和洛谷上线段树的模板1是同一道题. 由于本题中每个数的初始值都为\(0\), ...

  4. C. Polygon for the Angle 几何数学

    C. Polygon for the Angle 几何数学 题意 给出一个度数 ,问可以实现的最小的n的n边形是多少 思路 由n边形的外角和是180度直接就可以算出最小的角是多少 如果给出的度数是其最 ...

  5. 解决Macbook Pro蓝牙不可用问题

    谷歌搜索了下,在威锋网看到一个帖子,需要关机重置电源管理单元和系统NVRAM恢复出厂设置,具体操作如下:1.关机2.同时按下shift+control+option+power,保持5秒左右3.先按下 ...

  6. AJAX-状态属性

    XMLHttpRequest对象的readyState属性 作用:表示xhr对象的请求状态 值:由0到4表示5个状态 0:请求尚未初始化 1:已经打开到WEB服务器的连接,正在向服务器发送请求 2:请 ...

  7. xhr 的 onpregress 监听上传数据的 已上传 和 总大小

    var fd=new FormData(); $('.mwd_uppingzheng_btna_ok').on('click',function () { // 数组转 str var strarr= ...

  8. MyBatis-config.xml示例

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC ...

  9. css transform 2D3D转换

    2D转换 translate 移动 <style> div{ width: 100px; height: 100px; } .box{ border: 1px dashed red; fl ...

  10. SpringCloud Netflix Ribbon

    Eureka客户端的负载均衡:从Eureka server拿到节点列表,客户端自己使用负载均衡的算法确定要使用的节点: Eureka服务端的负载均衡:服务端使用负载均衡的算法,从节点列表中确定要使用的 ...