Page 1 of 1

Issue with notify-service-by-email command

Posted: Thu Sep 07, 2017 5:04 pm
by Sampath.Basireddy
I am trying to use notify-service-by-email command to send out email alerts, but doesn't seem to be working.

Here is the syntax of the command:

Code: Select all

/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$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
Any thoughts.



Thank You.

Re: Issue with notify-service-by-email command

Posted: Fri Sep 08, 2017 9:58 am
by tgriep
Can you go to the Admin > Manage Email settings menu and post the Mail Method the server is setup to use?
To use the notify-service-by-email command, the server has to be using Sendmail as the mail method.
If the server is setup to use a SMTP server, the command would have to use is xi_service_notification_handler for that user account.

You may want want to take a look at these documents for more details.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: Issue with notify-service-by-email command

Posted: Fri Sep 08, 2017 11:55 am
by Sampath.Basireddy
Yes, we are using "Sendmail" mail method.

Re: Issue with notify-service-by-email command

Posted: Fri Sep 08, 2017 1:24 pm
by scottwilkerson
So you have that method assigned to a contact and the contact assigned to a host/service that is going down correct?

Can you post the configuration for the contact (feel free to block out email address )

Re: Issue with notify-service-by-email command

Posted: Fri Sep 08, 2017 2:30 pm
by Sampath.Basireddy
Here is the contact config from contacts.cfg.

Code: Select all

define contact {
        contact_name                            IT-Monitoring
        alias                                   DL for IT-Monitoring
        host_notifications_enabled              1
        service_notifications_enabled           1
        host_notification_period                xi_timeperiod_24x7
        service_notification_period             xi_timeperiod_24x7
        host_notification_options               d,u,r,f,s,
        service_notification_options            w,u,c,r,f,s,
        host_notification_commands              notify-host-by-email
        service_notification_commands           notify-service-by-email
        email                                   <Email ID>
        use                                     generic-contact
        }

Re: Issue with notify-service-by-email command

Posted: Fri Sep 08, 2017 2:44 pm
by scottwilkerson
scottwilkerson wrote:So you have that method assigned to a contact and the contact assigned to a host/service that is going down correct?
Also, can you describe what is happening?

Can you see the notification in the Notification Report?

Can you see the email attempt in /var/log/maillog ?

Re: Issue with notify-service-by-email command

Posted: Mon Sep 11, 2017 4:01 pm
by Sampath.Basireddy
Yes, I do see an email attempt .

Code: Select all

Sep 11 16:49:49 <SRV> sendmail[30018]: v8BKnmnp030018: from=nagios, size=717, class=0, nrcpts=1, msgid=<201709112049.v8BKnmnp030018@<SRV>.ux.corp.local>, relay=nagios@localhost
Sep 11 16:49:49 <SRV> sendmail[30097]: v8BKnn6o030097: from=<nagios@<SRV>.ux.corp.local>, size=986, class=0, nrcpts=1, msgid=<201709112049.v8BKnmnp030018@<SRV>.ux.corp.local>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Sep 11 16:49:49 <SRV> sendmail[30018]: v8BKnmnp030018: to=<mail ID>, ctladdr=nagios (13802/13802), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30717, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v8BKnn6o030097 Message accepted for delivery)
Sep 11 16:49:49 <SRV> sendmail[30110]: STARTTLS=client, relay=mailrelay.ad.corp.local., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256/256
Sep 11 16:49:49 <SRV> sendmail[30110]: v8BKnn6o030097: to=<mail ID>, ctladdr=<nagios@<SRV>.ux.corp.local> (13802/13802), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120986, relay=mailrelay.ad.corp.local. [<IP>], dsn=2.0.0, stat=Sent (OK 9F/FA-28793-236F6B95)
Sep 11 16:50:18 <SRV> sendmail[1708]: v8BKoISG001708: Authentication-Warning: <SRV>.ux.corp.local: nagios set sender to [email protected] using -f

Re: Issue with notify-service-by-email command

Posted: Mon Sep 11, 2017 4:23 pm
by scottwilkerson
This shows the nagios server delivered the message to the next mail server, if it wasn't delivered you would need to check logs on that server

Code: Select all

Sep 11 16:49:49 <SRV> sendmail[30110]: v8BKnn6o030097: to=<mail ID>, ctladdr=<nagios@<SRV>.ux.corp.local> (13802/13802), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120986, relay=mailrelay.ad.corp.local. [192.168.5.90], dsn=2.0.0, stat=Sent (OK 9F/FA-28793-236F6B95)