Hey,
I am currently setting up email notifications using director. I’ve installed msmtp and created the file /etc/msmtprc with the following lines:
defaults
auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
Infrastructure email account
account IcingaEmail
host email-smtp.****.com
port 587
from smtp-email
user ******
password *****
Set a default account
account default : IcingaEmail
I was able to send and email using the command
/usr/bin/printf “To:my@email.com\nFrom:\nSubject:Icinga Host Down\n\nPlease Fix!” | /usr/bin/msmtp my@email.com
I even verified running the command as the nagios user and the email still sends
The issue I am having is setting up the command and receiving a email through director.
After configuring my contacts/contact groups, notification/notifications template and implementing the command above I don’t no receive a email when I manually take my satellite host down.
When clicking into my host alive check I do see notifications being sent for example.
and checking in the icinga2.log
[2020-03-09 12:18:18 -0600] information/Checkable: Checkable ‘satellite1’ has 1 notification(s). Checking filters for type ‘Problem’, sends will be logged.
[2020-03-09 12:18:18 -0600] information/Notification: Sending ‘Problem’ notification ‘satellite1!Satellite Down’ for user ‘Test User’
[2020-03-09 12:18:18 -0600] information/Notification: Completed sending ‘Problem’ notification ‘satellite1!Satellite Down’ for checkable ‘satellite1’ and user ‘Test User’ using command ‘Email-Notification’.
No email is received though
I’m wondering if I need to configure the command to use variables based on the user contact and check name/state. I wanted to get a basic command working first without using any variables thinking I could implement the variables later on.
Also I dont see any default plugin-notification-commands with director, so I’m thinking I will have to setup my own custom fields/arguments to be used as command variables.
I need some further guidance on getting my command to work, The documentation Ive found uses a command with this style
command_line /usr/bin/printf “%b” “***** Icinga ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | @MAIL_PROG@ -s " $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$.
but msmtp has a slightly different format which might be the cause of the issue I’m having
Thanks in advance.