Page 1 of 1

Email notification

Posted: Wed Apr 12, 2017 12:36 am
by Nessero
Hi ! Configure nagios and postfix to send email and nothing work.

nagios command.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" | /usr/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" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }
postfix configure like this http://www.telnetport25.com/2012/02/con ... gios-core/ and relay https://www.freelock.com/kb/postfix-relayhost
Send custom messega from web of nagios and its dont delivered.
in /var/log/nagios/ :

Code: Select all

[1491974038] Successfully launched command file worker with pid 27238
[1491974062] EXTERNAL COMMAND: SEND_CUSTOM_HOST_NOTIFICATION;server1;0;Nagios Admin;test
postfix log is empy

Re: Email notification

Posted: Wed Apr 12, 2017 10:51 am
by mcapra
Did you follow a particular guide for the Nagios end of things when setting this up?

Does your contact have the proper host_notification_commands and service_notification_commands set?

Can you share the output of which mail? The default Linux MTA doesn't typically recognize Postfix unless you tell it to.

Re: Email notification

Posted: Wed Apr 12, 2017 10:25 pm
by Nessero
mcapra wrote:Did you follow a particular guide for the Nagios end of things when setting this up?

Does your contact have the proper host_notification_commands and service_notification_commands set?

Can you share the output of which mail? The default Linux MTA doesn't typically recognize Postfix unless you tell it to.
Yep i don't set notification commands in contact.cfg. Anover question. Where configure how often notifications sent to mail ?

Re: Email notification

Posted: Thu Apr 13, 2017 1:29 pm
by mcapra
That would be done with the notification_interval and notification_timeperiod in your service/host definitions.

More info here:
https://assets.nagios.com/downloads/nag ... tions.html

Re: Email notification

Posted: Thu Apr 13, 2017 10:33 pm
by Nessero
mcapra wrote:That would be done with the notification_interval and notification_timeperiod in your service/host definitions.

More info here:
https://assets.nagios.com/downloads/nag ... tions.html
Thx to you.

Re: Email notification

Posted: Fri Apr 14, 2017 7:55 am
by dwhitfield
Did you have any more questions or are we ready to close? Thanks!

Re: Email notification

Posted: Tue Apr 18, 2017 11:16 pm
by Nessero
dwhitfield wrote:Did you have any more questions or are we ready to close? Thanks!
Ready to close. Thanks!