如何将 nagios 警报通过电子邮件发送到我的 gmail?

jrg*_*jrg 7 server nagios3

我想设置某种邮件服务器来将电子邮件从我的 gmail 帐户发送到另一封电子邮件。我怎样才能做到这一点?

jrg*_*jrg 7

首先,安装 sSMTP,因为在这种情况下 postfix 是矫枉过正的。是的,这将删除后缀。我们关心吗?并不真地。

sudo apt-get install ssmtp
Run Code Online (Sandbox Code Playgroud)
  1. 通过编辑配置 sSMTP /etc/ssmtp/ssmtp.conf
#Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=yourusername@gmail.com
#I recommend setting this 

mailhub=smtp.gmail.com:587

# Where will the mail seem to come from?
rewriteDomain=

#The full hostname
hostname=[some hostname here]
UseTLS=YES
UseSTARTTLS=YES
AuthMethod=LOGIN
AuthUser=yourusername@gmail.com
AuthPass=yourpassword

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
# This is optional if you're going to use revaliases - I didn't
FromLineOverride=YES
Run Code Online (Sandbox Code Playgroud)

现在,我们需要设置权限/etc/ssmtp/ssmtp.conf帮助(这不是万无一失)保护您的明文密码。

sudo chown root:nagios /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf
Run Code Online (Sandbox Code Playgroud)

重新启动 nagios,你应该设置好了。

sudo service nagios3 restart
Run Code Online (Sandbox Code Playgroud)