Seperate service notifications

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.
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Seperate service notifications

Post by JohnFLi »

Hello, I'm rather new to Nagios, I have seen it run, and used it before, but never managed it.

Anyway, I have a few machines that only need to be checked they are still alive. For these machines, if they don't respond (appear dead) I want a single person to be notified.
I created a Host Group called Ping_Only for these machines and have the check_Ping service pointing at that group.

but in testing, the people that are listed as contacts for the Ping service are notified, and not the person that is assigned to the machine.

Is there a way to have nagios send notifications to the Host Contact instead of the service contact??
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Seperate service notifications

Post by eloyd »

You can change the notification command to use the notify-host-by-email (or whatever it's called on your system) instead of the service-notify-by-email command, but you'd have to change the formatting to service-specific things instead of host-specific things.

Why not just change the contact(s) on the service(s) to be the same as on the host(s)?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Seperate service notifications

Post by JohnFLi »

Why not just change the contact(s) on the service(s) to be the same as on the host(s)?
On Server A (for example), if the C Drive is getting to full, Bob needs to be notified.
On Server B, if the C Drive gets full, Frank needs to get notified., and for the sake of having fun, notify frank every minute. (he gets distracted easy)

notify-host-by-email
Ahhhhhhh, I thought that was just for if the HOST machine was down.

So using my example above, if I understand correctly, if I set the C Drive check to:

Code: Select all

check_period                   	24x7
	event_handler                  	notify-host-by-email
	notification_interval          	5
	notification_period            	24x7
	notification_options           	w,c,r
	notifications_enabled          	1
	contacts                       	Server_Alerts
	contact_groups                 	TEXT_GROUP
the host config

Code: Select all

active_checks_enabled          	1
	check_period                   	Customer-Service-Normal-Hours
	contacts                       	Frank
	notification_interval          	60
It will only send notifications to Frank that is set as the contact for that Host



while if I have it set as:

Code: Select all

check_period                   	24x7
	event_handler                  	notify-service-by-email
	notification_interval          	5
	notification_period            	24x7
	notification_options           	w,c,r
	notifications_enabled          	1
	contacts                       	Server_Alerts
	contact_groups                 	TEXT_GROUP
It will send the notifications to Server-Alerts and TEXT_GROUP that is set as the contact for just that service.
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Seperate service notifications

Post by eloyd »

Yes, but remember to look at the commands.cfg definition for those notify commands. They send different things (one is expecting to tell people about a host and one about a service).
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Seperate service notifications

Post by JohnFLi »

I don't see anything special. Or am I not understanding what you are asking me to check in the commands.cfg file

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

# '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: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
	}
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Seperate service notifications

Post by eloyd »

notify-host-by-email sends information that includes:
Host: $HOSTNAME$\nState: $HOSTSTATE$\n
notify-service-by-email sends:
Service: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$
The host notification command doesn't send any service-related information because it's not designed to. So if you use this approach, you may want to just create a third command and copy "notify-service-by-email" to "notify-service-by-email-use-host-contact" and use that for the notification command so that it will use the host contact instead of the service contact.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Seperate service notifications

Post by JohnFLi »

I think I understand what your saying. I will test things out and see what happens. Thank you
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Seperate service notifications

Post by eloyd »

Good luck. I've been using Nagios for 14 years, so I sometimes forget some of the "more basic" stuff. Let me know if there's anything I glossed over that you need more help with.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Seperate service notifications

Post by JohnFLi »

well, I tried the option you suggested and that didn't really seem to make an difference, perhaps I didn't do it correctly.

But what I did, and this works (I suppose lol)

The from individual services, service templates, host templates, I remove the contact info. (Granted Nagios doesn't like that, but it deals with it)
Then for the Host config, I put the 'owner' for that server as the contact. that way that person gets notified with anything that is up with that server.

My next plan is to setup an escalation so that if Frank (or anybody else) is being too lazy to fix or acknowledge an issue, then a group of people will get notified, then after a bit another group with get notified.

At least that is what I want to do.
Everybody is somebody else’s weirdo
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Seperate service notifications

Post by eloyd »

Well that's what escalations are for, so you're on track with that. If you want to try to do more with the other issue(s), PM me and we'll talk offline.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Locked