1. Installation of MSMTP and Mutt
Related software can search the Web on its own
1.1, MSMTP Installation
TAR-XF MSMTP-1.6.2.TAR.XZ
CD msmtp-1.6.2
./configure
Make && make install
1.2, Mutt Installation
Yum-y Install Mutt
2. Configuring MSMTP and Mutt
2.1, Configuration Msmtp
Vim/usr/local/etc/msmtprc
Account Default
Host smtp.163.com #不同的提供商smtp地址不相同, find your own
TLS off
Auth Plain #邮箱验证方式
From Xxx@163.com #xxx改为你的邮箱用户名
User xxx
Password ****** #输入你的邮箱密码
Logfile/var/log/msmtp.log #log路径可以随意定义
chmod 600/USR/LOCAL/ETC/MSMTPRC #因为使用明文密码, so you need to modify permissions
2.2, Configuration Mutt
Vim/etc/muttrc
Set sendmail= "/usr/local/bin/msmtp"
Set Use_from=yes
Set Realname= "George"
Set [email protected]
Set Envelope_from=yes
2.3. Test Mail sending
echo "Good lucky" | /usr/bin/mutt-s "Hello George" [email protected]
3. Zabbix Configuration
3.1. Allow Zabbix to use scripts
Vim/usr/local/zabbix/etc/zabbix_server.conf
Alertscriptspath=/usr/local/zabbix/share/zabbix/alertscripts #该脚本路径可以随意指定
3.2, write the script to send the message
vim/usr/local/zabbix/share/zabbix/alertscripts/send_mail.sh
#!/bin/bashecho "$" | /usr/bin/mutt-s "$" $ #备注: $3:zabbix mail content, $2:zabbix mail header, $1:zabbix set recipient address;
3.3. Set up a script to send mail
Management "Warning Medium type" fill in "Name", "type", "Script name" (The script name corresponds to the script name specified in zabbix_server.conf).
650) this.width=650; "title=" 1.jpg "alt=" wkiom1zr8qfdkeq3aaho6avxkam611.jpg "src=" http://s4.51cto.com/wyfs02/M00/ 76/61/wkiom1zr8qfdkeq3aaho6avxkam611.jpg "/>
3.4, set the alarm mail network recipient
3.4.1, manage users Add user group Add User user, fill in user information "Warning medium, select" type ", fill in the recipient's email address or
3.4.2, Management "users" use existing user groups "Add Users" users, fill in user information "Warning medium, select" type ", fill in the recipient's e-mail address
650) this.width=650; "title=" 3.jpg "alt=" wkiom1zr8dqtfxb0aaiedvdh_qc978.jpg "src=" http://s2.51cto.com/wyfs02/M02/ 76/61/wkiom1zr8dqtfxb0aaiedvdh_qc978.jpg "/>
650) this.width=650; "title=" 2.jpg "alt=" wkiom1zr8ydcslyuaaddcwdlv9q714.jpg "src=" http://s3.51cto.com/wyfs02/M01/ 76/61/wkiom1zr8ydcslyuaaddcwdlv9q714.jpg "/>
3.5. Set the action
Configuration "Action" create action
(Create an action, you can refer to my other blog post: http://small.blog.51cto.com/259970/1715237)
650) this.width=650; "title=" 4.jpg "alt=" wkiol1zr8m6qxfx6aanlblgvyx8800.jpg "src=" http://s2.51cto.com/wyfs02/M02/ 76/60/wkiol1zr8m6qxfx6aanlblgvyx8800.jpg "/>
Complete.
This article is from the "Super_color" blog, make sure to keep this source http://small.blog.51cto.com/259970/1715813
Zabbix using a script to send an out-of-network message alert (MSMTP + mutt)