Issue with notify-service-by-email command

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

Issue with notify-service-by-email command

Post 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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

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

Post by Sampath.Basireddy »

Yes, we are using "Sendmail" mail method.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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 )
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

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

Post 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
        }
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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 ?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Sampath.Basireddy
Posts: 252
Joined: Wed Dec 14, 2016 12:30 pm

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

Post 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
Last edited by Sampath.Basireddy on Mon Sep 11, 2017 4:56 pm, edited 1 time in total.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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)
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked