Page 2 of 5

Re: Problem with enabling notifications with postfix

Posted: Wed Jul 08, 2015 3:32 pm
by tgriep
You would edit the 2 commands shown below and add -r [email protected] to the end of the command_line.
Remember to replace [email protected] with a real email address.

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$\nAd
dress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE
$ **" $CONTACTEMAIL$  -r [email protected]
        }

# '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: $HOSTALI
AS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIF
ICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -r [email protected]
        }

Re: Problem with enabling notifications with postfix

Posted: Wed Jul 08, 2015 4:23 pm
by Jessuzz94
It doesnt work u.u, in the mail.log dont show me anything information, if the notifications cant sends, or yes, nothing:/, i think that is bad configuration that i do to postfix to run the notifications

Re: Problem with enabling notifications with postfix

Posted: Thu Jul 09, 2015 9:12 am
by tgriep
I will need to get your configuration files to debug this issue. I will need the nagios.cfg file. I will need the contact, host and service configurations for one of the systems you are checking.
You can either post them here or PM the files to me.

Re: Problem with enabling notifications with postfix

Posted: Thu Jul 09, 2015 1:55 pm
by Jessuzz94
There is something:

Re: Problem with enabling notifications with postfix

Posted: Thu Jul 09, 2015 4:10 pm
by jdalrymple
Jessuzz94 wrote:The command "tail -f /var/log/maillog" doesnt work, says no such file in directory, i use ubuntu server i think is that.

The invalid address shows me this in the mail.log, i can send mails to everybody, but the notifications of nagios doesnt work, i configured contacts , commands , host and services to enable notifications and short intervals test if works.

Code: Select all

Jul  7 14:50:18 ubuntu postfix/pickup[1073]: 4793315FCB2: uid=1001 from=<nagios>
Jul  7 14:50:18 ubuntu postfix/cleanup[2155]: 4793315FCB2: message-id=<20150707215018.4793315FCB2@ubuntu>
Jul  7 14:50:18 ubuntu postfix/qmgr[1074]: 4793315FCB2: from=<nagios@ubuntu>, size=422, nrcpt=1 (queue active)
Jul  7 14:50:18 ubuntu postfix/smtp[2157]: warning: database /etc/postfix/sasl_passwd.db is older than source file /etc/postfix/sasl_passwd
Jul  7 14:50:21 ubuntu postfix/smtp[2157]: 4793315FCB2: to=<[email protected]>, relay=smtp.gmail.com[173.194.64.109]:587, delay=2.8, delays=0.03/0.02/1.7/1, dsn=2$
Jul  7 14:50:21 ubuntu postfix/qmgr[1074]: 4793315FCB2: removed
What was it you did that worked? I'm still thinking this is likely a mail server setup issue - not a Nagios issue.

Re: Problem with enabling notifications with postfix

Posted: Fri Jul 10, 2015 11:23 am
by Jessuzz94
i tought that was problem of both

Re: Problem with enabling notifications with postfix

Posted: Fri Jul 10, 2015 11:41 am
by jdalrymple
jdalrymple wrote:What was it you did that worked?
Please answer that question. The aforementioned excerpt of maillog indicates a successfully sent E-mail. How did that get sent?

Re: Problem with enabling notifications with postfix

Posted: Fri Jul 10, 2015 1:15 pm
by Jessuzz94
it sends emails succesfully with the command | mail -s "test" [email protected], but doesnt send notifications to the nagios email that i configured.

Re: Problem with enabling notifications with postfix

Posted: Fri Jul 10, 2015 1:37 pm
by tgriep
Could you check your nagios.cfg file and check to see in notifications are enabled like below?

Code: Select all

enable_notifications=1
If it is not, set it to 1 and restart nagios

Code: Select all

service nagios restart

Re: Problem with enabling notifications with postfix

Posted: Fri Jul 10, 2015 1:51 pm
by jdalrymple
We need to see your notification commands, notify-host-by-email and notify-service-by-email.