我怎样才能将 nagios 警报通过电子邮件发送到我的 Gmail?

我怎样才能将 nagios 警报通过电子邮件发送到我的 Gmail?

我想设置某种邮件服务器,以便将电子邮件从我的 Gmail 帐户发送到另一个电子邮件帐户。我该怎么做?

答案1

首先,安装 sSMTP,因为在这种情况下,postfix 有点多余。是的,这将删除 postfix。我们关心吗?其实不关心。

sudo apt-get install ssmtp
  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.
[email protected]
#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
[email protected]
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

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

sudo chown root:nagios /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.conf

重新启动 nagios 然后就设置好了。

sudo service nagios3 restart

相关内容