I've been trying to configure my nagios so that it sends notifications to a gmail account.
So far it does not seem to work, I did the following
Code: Select all
sudo apt-get install ssmtpCode: Select all
#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=harenhall.the.realm
UseTLS=YES
UseSTARTTLS=YES
AuthMethod=LOGIN
[email protected]
AuthPass=nagios852
# 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=YESCode: Select all
sudo chown root:nagios /etc/ssmtp/ssmtp.conf
sudo chmod 640 /etc/ssmtp/ssmtp.confCode: Select all
#'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Code: Select all
May 17 11:05:12 lannister sendmail[4550]: alias database /etc/mail/aliases rebuilt by administrator
May 17 11:05:12 lannister sendmail[4550]: /etc/mail/aliases: 0 aliases, longest 0 bytes, 0 bytes total
May 17 11:05:13 lannister sm-mta[4616]: starting daemon (8.14.4): SMTP+queueing@00:10:00
