Hello,
I just installed Nagios Core 4.2.2 in a new Ubuntu server 16.04 with Postfix.
Contact_group is added in each host and service with 24x7 and so on....
Postfix is configure to relay emails to Office 365. I am able to send a test email using below command, but I don't receive any notification email from Nagios.
$ echo "This is a test email from Ubuntu server" | mail -s "Relay Test Email" [email protected] -a "FROM:[email protected]"
Of course I have been reading but end up confused and lost.
Any help is more than Welcome please.
Thanks in advance
myt
Nagios email notification to Office 365 not working
Nagios email notification to Office 365 not working
Last edited by dwhitfield on Wed Nov 02, 2016 9:41 am, edited 1 time in total.
Reason: marking with green check mark
Reason: marking with green check mark
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Nagios email notification to Office 365 not working
Could you post your command definitions? Thanks!
Re: Nagios email notification to Office 365 not working
Command definitions are as follow (notify by email):
# '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$
}
Thanks
# '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$
}
Thanks
Re: Nagios email notification to Office 365 not working
What is the output of which mail? The core commands as you can see are simply passing the printf data to /bin/mail. If which mail reports /bin/mail, then this should work fine.
Next step, is looking at how you specified the from address. Take a look at when your notification fires in Nagios, and look at /var/log/maillog - if you see something indicating it was rejected, or bounced, then the likely cause is it being blocked due to an invalid sender. You may want to append to your notify-host/service-by-email commands the -a parameter you were passing in your testing.
For example -
This should send the same exact way your testing was.
Next step, is looking at how you specified the from address. Take a look at when your notification fires in Nagios, and look at /var/log/maillog - if you see something indicating it was rejected, or bounced, then the likely cause is it being blocked due to an invalid sender. You may want to append to your notify-host/service-by-email commands the -a parameter you were passing in your testing.
For example -
Code: 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$ -a "FROM:[email protected]"
}
Former Nagios Employee
Re: Nagios email notification to Office 365 not working
THANKSSSSS for your help
It is working now, just changed to /usr/bin/mail and added the -a "FROM: "
I got the critical as well as the recovery notification!!!
Have a wonderful evening rkennedy!
It is working now, just changed to /usr/bin/mail and added the -a "FROM: "
I got the critical as well as the recovery notification!!!
Have a wonderful evening rkennedy!
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Nagios email notification to Office 365 not working
Glad to hear it is resolved. Is it ok if we lock the thread? Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!
Re: Nagios email notification to Office 365 not working
Hi dwhitfield,
Yes, it is OK to lock the thread, please proceed.
Hoping this help other people.
Thanks a lot Nagios forums!
Loving Nagios
Yes, it is OK to lock the thread, please proceed.
Hoping this help other people.
Thanks a lot Nagios forums!
Loving Nagios