#启动邮箱服务
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. 线性回归-Fork

    线性回归 主要内容包括: 线性回归的基本要素 线性回归模型从零开始的实现 线性回归模型使用pytorch的简洁实现   线性回归的基本要素 模型 为了简单起见,这里我们假设价格只取决于房屋状况的两个因 ...

  2. 每天进步一点点------Xilinx IP 内核

    ISE 设计套件 11.1 版本中提供了众多全新的 IP 内核.数学函数:Multiply Adder v2.0 —— 执行两个操作数的乘法,并采用 XtremeDSP™ 解决方案切片将完全精确的乘积 ...

  3. 【做题笔记】洛谷P1002过河卒

    虽说是 dp 入门题,但还是有很多细节需要注意 如果设 \(f_{x,y}\) 为目标地点为 \((x,y)\) 时走的种数,那么答案就是 \(f_{n,m}\) 在不考虑那只讨厌的马的情况下,对于任 ...

  4. Makefile中的wildcard/notdir/patsubst

    在Makefile规则中,通配符会被自动展开. 但在变量的定义和函数引用时,通配符将失效.这种情况下如果需要通配符有效,就需要使用函数“wildcard”,它的用法是:$(wildcard PATTE ...

  5. Object.fromEntries

    //数组转换成对象 const arr = [['foo', 1],['bar', 2]] const obj = Object.fromEntries(arr) console.log(obj.ba ...

  6. HDU - 5187 zhx's contest(快速幂+快速乘法)

    作为史上最强的刷子之一,zhx的老师让他给学弟(mei)们出n道题.zhx认为第i道题的难度就是i.他想要让这些题目排列起来很漂亮. zhx认为一个漂亮的序列{ai}下列两个条件均需满足. 1:a1. ...

  7. 设置DataGridView的单元格颜色

    RowPrePaint事件: private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArg ...

  8. 【音乐欣赏】《PANTA RHEI》 - MYTH & ROID

    曲名:PANTA RHEI 作者:MYTH & ROID [ti:PANTA RHEI (<异世界超能魔术师>TV动画片头曲)] [ar:MYTH & ROID] [al: ...

  9. git相关项目迁移

    1). 从原地址克隆一份裸版本库,比如原本托管于 GitHub. git clone --bare git://github.com/username/project_old.git --bare 创 ...

  10. bootstrap的pillbox使用

    使用bootstrap的cameo模版,搭建了一个cms系统,使用pillbox做显示的时候,出现点击×失败的问题. 分析了一下pillbox这个控件的使用方法. pillbox的样例在cameo/f ...