Page 1 of 1

Mail notification

Posted: Thu Sep 06, 2012 3:19 am
by cesco_78
Hello,
I'm a newbe on nagios core and I've a problem...

I configured nagios and postfix, but there is something that doesn't work in mail notification.

When i send a test email from the webgui, this email is sent and arrives correctly, but if i try to configure an automatic notification, the mail il sent to a "strange" address...

In maillog I've:

Test email

Code: Select all

Sep  6 09:47:23 nagios postfix/qmgr[15230]: 40871BFCC1: from=<[email protected]>, size=658, nrcpt=1 (queue active)
Sep  6 09:47:24 nagios postfix/smtp[12360]: 40871BFCC1: to=[b]<[email protected]>[/b], relay=172.20.9.10[172.20.9.10]:25, delay=0.9, delays=0.05/0.04/0.02/0.8, dsn=2.6.0, status=sent (250 2.6.0 <[email protected]> [InternalId=77259] Queued mail for delivery)
Automatic email

Code: Select all

Sep  6 10:06:36 nagios postfix/pickup[13611]: 65E2BBFD22: uid=501 from=<nagios>
Sep  6 10:06:36 nagios postfix/cleanup[13660]: 65E2BBFD22: message-id=<[email protected]>
Sep  6 10:06:36 nagios postfix/qmgr[13612]: 65E2BBFD22: from=<[email protected]>, size=634, nrcpt=1 (queue active)
Sep  6 10:06:36 nagios postfix/local[13664]: 65E2BBFD22: to=[b]<[email protected]>[/b], orig_to=<$>, relay=local, delay=0.32, delays=0.2/0.05/0/0.07, dsn=5.1.1, status=bounced (unknown user: "$")
In automatic email I need to have <[email protected]> in "to" field

Please, someone can help me?

Thank You

Best Regards

Re: Mail notification

Posted: Thu Sep 06, 2012 1:57 pm
by agriffin
Can you post an example contact definition that isn't receiving notifications correctly?

Re: Mail notification

Posted: Fri Sep 07, 2012 2:25 am
by cesco_78
Hello, this is my contacts.cfg

Code: Select all

define contact {
        contact_name                            nagiosadmin
        alias                                   Nagios Admin
        host_notifications_enabled              1
        service_notifications_enabled           1
        host_notification_period                24x7
        service_notification_period             24x7
        host_notification_options               d,u,r,f,s,n
        service_notification_options            w,u,c,r,f,s,n
        host_notification_commands              notify-host-by-email
        service_notification_commands           notify-service-by-email
        email                                   [email protected]
        use                                     generic-contact
        }


Thank You!

Re: Mail notification

Posted: Sun Sep 09, 2012 5:43 pm
by jsmurphy
Are you also able to post your email command definition from commands.cfg? Usually called notify-by-email .

Re: Mail notification

Posted: Mon Sep 10, 2012 1:37 am
by cesco_78
Hello,
there are the commands

notify-host-by-email

Code: Select all

 /usr/bin/printf "%b" "***** Nagios/Socbox *****\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

Code: Select all

/usr/bin/printf "%b" "***** Nagios/Socbox *****\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 -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Thank You!

Re: Mail notification

Posted: Mon Sep 10, 2012 5:28 am
by pathana
in that command change the /bin/mail to /usr/bin/mailx
it wrks for me try it out

Re: Mail notification

Posted: Mon Sep 10, 2012 9:35 am
by cesco_78
Hello, I changed the command, but the maillog remain empty, no notification arrives to postfix

Re: Mail notification

Posted: Mon Sep 10, 2012 5:44 pm
by jsmurphy
First of all change it back to /bin/mail, you were already using the right mail client for your OS.

The problem is this: When nagios outputs the character "$" from a macro that means one of two things, either a. the macro is empty or b. the macro has been typed wrong. We can see that your $CONTACTEMAIL$ macro has been typed correctly so it's not problem b. The fact you are getting $@domain is really weird because normally you would get only "$" and nothing else, are there any special characters in your admins name?