Page 1 of 1

email notifications

Posted: Wed Sep 02, 2015 8:19 pm
by Pikmin
Hi there,
Can someone assist me with setting up the email monitoring. I'm running core 4.1.1 on Centos 7.
The postfix service is running however I haven't made any changes

Code: Select all

define contact{
        contact_name              nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user
        email                          nagios@localhost <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        }
Is it enough to change nagios@localhost to my internal exchange address or is there additional steps I need to make
Thanks

I might have posted this in the wrong forum, sorry!

Re: email notifications

Posted: Wed Sep 02, 2015 10:13 pm
by Box293
Pikmin wrote:Is it enough to change nagios@localhost to my internal exchange address or is there additional steps I need to make
That will change who the email goes to.

Have a look at the notify-host-by-email and notify-service-by-email commands, this is how the nagios submits the emails.

Re: email notifications

Posted: Wed Sep 02, 2015 10:39 pm
by Pikmin
Thanks Box293
I noticed I didn't have mail installed, which mail doesn't return anything
I have installed mailx and it resides in /usr/bin/mail

Does that mean I should add /usr to /bin/mail below:
commands.cfg

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$
	}

# '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\n
Date/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
	}
EDIT: It appears to be working now, I received my first alert :)

Re: email notifications

Posted: Wed Sep 02, 2015 11:12 pm
by Box293
Pikmin wrote:Does that mean I should add /usr to /bin/mail below:
Yes, update the command.
Pikmin wrote:EDIT: It appears to be working now, I received my first alert :)
Excellent, happy monitoring :D

Re: email notifications

Posted: Thu Sep 03, 2015 12:01 am
by Pikmin
Thanks mate :)
Can be closed as solved