Setup Email Notifications in Nagios Core

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Setup Email Notifications in Nagios Core

Postby nib01 » Wed Oct 10, 2018 9:52 am

I have already installed Nagios Core (latest version) on centos 7.

Our company is currently using office 365 outlook as mail client, and would like to use SMTP, or what do you recommend as the best to use on Centos 7?

Id like to setup an email account that could send email from using nagios-email_alert@company.com. This account should be only send email but does not receive.
nib01
 
Posts: 1
Joined: Tue Oct 09, 2018 9:31 am

Re: Setup Email Notifications in Nagios Core

Postby cdienger » Wed Oct 10, 2018 4:37 pm

I don't have any personal experience with either, but finding a tutorial on setting up a sendmail relay to office 365 is more difficult to find than a postfix guide:

https://linuxhowtoguide.blogspot.com/20 ... relay.html
https://geekdudes.wordpress.com/2018/04 ... ffice-365/

Some other links of interest:

viewtopic.php?f=34&t=46180
viewtopic.php?f=26&t=39588
https://exchange.nagios.org/directory/T ... on/details
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
cdienger
Support Tech
 
Posts: 1862
Joined: Tue Feb 07, 2017 11:26 am

Re: Setup Email Notifications in Nagios Core

Postby scottwilkerson » Wed Oct 10, 2018 4:53 pm

This really is more of a server admin question, but at a basic level on a CentOS machine you should be able to modify your notification commands and add a
Code: Select all
-r nagios-email_alert@company.com


so something like this:
Code: Select all
define command {
    command_name    notify-host-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -r nagios-email_alert@company.com -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

define command {
    command_name    notify-service-by-email
    command_line    /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -r nagios-email_alert@company.com -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}


per man mail
Code: Select all
-r address
              Sets the From address. Overrides any from variable specified in environment or startup files.  Tilde escapes are disabled.  The -r address options are passed  to  the  mail
              transfer agent unless SMTP is used.  This option exists for compatibility only; it is recommended to set the from variable directly instead.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12020
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises


Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 12 guests