Sporadic alert/recovery email issue

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Sporadic alert/recovery email issue

Post by neworderfac33 »

Good afternoon.

Please could you advise if there is a way to send a test email to a named recipient from the command line?

I'm encountering issues with a specific host/service definition combination whereby alert/recovery emails don't always get sent to multiple contacts listed against the host when I change the threshold in the service (in this case E drive available space).

Also, if my host definition USEs the template "windows-server" (which in turn USEs the template "generic-host") and my service USEs the "generic-service" template and both of them have defined contacts and contact groups (but the host definition doesn't), which set of contacts will be used for alerting - those in "windows-server" or those in "generic-service"?

Finally, am I correct in assuming that alerting recipients can be defined by both contacts AND contact-groups?

Regards and thanks in advance

Pete
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Sporadic alert/recovery email issue

Post by scottwilkerson »

This is a deep subject and depends on several things.

It works based on what is outlined here
https://assets.nagios.com/downloads/nag ... tance.html

So, if you have something defined in the host it will over-write what is in the template, else the top template by precedence is used, UNLESS, you have additive inheritance setup on the the item.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Sporadic alert/recovery email issue

Post by dwhitfield »

In addition to what @ scottwilkerson said...

peterooney wrote: I'm encountering issues with a specific host/service definition combination whereby alert/recovery emails don't always get sent to multiple contacts listed against the host when I change the threshold in the service (in this case E drive available space).
This sounds like some contacts are not set up to receive warning notifications. Can you PM or post your contacts.cfg? Feel free to scrub.

The following will send an email...it will be pretty junk, but you can replace variables as necessary. I suppose the one requirement is to actually have an email.
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\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$

I'm not sure what you mean by contacts and contact-groups. Contact groups have contacts. You can't define contacts only in the contact groups. If you are asking if you can set both contacts and contact groups, then yes.

The host definition has nothing to do with the service definition except when the service pulls the host address. I think that answers your question about templates, but let me know if I am missing something.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Sporadic alert/recovery email issue

Post by neworderfac33 »

Thanks for the replies - I solved the problem by commenting out removing all the contact and contact groups in my service definitions and service templates, and those defined for the hosts and the host templates seem to be working just fine.

This thread can be closed.

Pete
Locked