Escalations - doesn't pick hostrgoup name

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.
airw
Posts: 10
Joined: Thu Jan 08, 2015 6:12 am

Escalations - doesn't pick hostrgoup name

Post by airw »

Hello

Having issues with host and service escalations sending via sms.

Original set up: host and service notifications are being sent via e-mail just fine - the way I want - 24x7.

Objective: based on current configuration - configure escalations to be notified by sms outside of working hours (nights, weekends) for just specific hosts/service group, not all of them.

Current status:
Configured host escalations with separate contact/contact_group to notify myself only via sms and keep sending e-mails to admins all the time.
E-mails work, but the escalation configuration doesn't seem to grab a hostgroup I want to be notified about (routers). It does send sms-es for all hosts and all host_groups instead. And also it picks the escalation option (hardstate) for all (down,recovery,unknown...), and I have escalations configured for down/recovery only.
Basically it escalates it all, whatever is set in host.cfg.

Relevant config below:

Briefly:
E-mail: I need notifications for all hosts and groups (works fine)
SMS: I just need escalations for routers only and for up/down state (currently sends for all hosts, host_groups and all hard states - up,down,unknown...)

hosts.cfg (template)

Code: Select all

define host {
        name                              generic-host   
        [b]register[/b]                   0      
        check_command              check-host-alive
        max_check_attempts       3    
        notification_interval          0   
        notification_period            24x7
        notification_options          d,u,r  
        contact_groups                admins, myself


my_server.cfg (real host)

Code: Select all

define host {
        use                             generic-host
        host_name                  my_server
        address                      server_ip_address
        hostgroups                 servers
}
my_router.cfg (other real host)

Code: Select all

define host {
        use                             generic-host
        host_name                  my_router
        address                      router_ip_address
        hostgroups                  routers
}
hostescalation.cfg

Code: Select all

define hostescalation{
        hostgroup_name          [b]routers[/b]
        first_notification           1
        last_notification           1
        notification_interval      1
        contact_groups            [b]myself[/b]
        escalation_period         24x7
        escalation_options       [b]d,r[/b]  #different from the host template
        }
contacts.cfg

Code: Select all

define contact{
        contact_name               admins
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-by-email
        host_notification_commands      host-notify-by-email
        email                           admins@domain.com
        }

        contact_name               myself
        service_notification_period     weekends
        host_notification_period        weekends
        service_notification_options   u,c
        host_notification_options       d,r
        service_notification_commands   notify-by-sms
        host_notification_commands      host-notify-by-sms
        email                           myself@domain.com
        pager                           my_phone#
        }
# contactgroups.cfg and timeperiods.cfg configure accordingly

-----
Overview:
I my understanding it should go as follows:
* host is being monitored 24x7 (as hostss.cfg states)
* host down (check_host_alive comamnd)
* admins being notified via e-mail (as per contact.cfg - 24x7)
* 'myself' notified via sms (only in case if: related to routers, host down or up, only during nigh and weekend)

But with this configuration I am in fact notified during night and weekends only but for all host groups and with all up/down/unknown states.

If I perform on the fly config check it shows that indeed escalations are configured with the number of hosts I want:

Code: Select all

Running pre-flight check on configuration data...
Checking service escalations...
	Checked 38 service escalations.
Checking host escalations...
	Checked 40 host escalations.
if I add both groups - routers and servers, it is seen by escalation config:
hostescalation.cfg

Code: Select all

define hostescalation{
        hostgroup_name          [b]routers, servers[/b]
        first_notification           1
        last_notification           1
        notification_interval      1
        contact_groups            [b]myself[/b]
        escalation_period         24x7
        escalation_options       [b]d,r[/b]  #different from the host template
        }

Code: Select all

Running pre-flight check on configuration data...
Checking service escalations...
	Checked 38 service escalations.
Checking host escalations...
	Checked 80 host escalations.
Either way I get sms-es for all hosts.
Am I missing something?
Appreciate.
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Escalations - doesn't pick hostrgoup name

Post by tgriep »

In your hosts.cfg (template), you need to make sure your SMS contact is not in either of these contact_groups "admins and myself".
You have this template applied to your hosts and routers, this could be why you are receiving SMS Notifications.
Be sure to check out our Knowledgebase for helpful articles and solutions!
airw
Posts: 10
Joined: Thu Jan 08, 2015 6:12 am

Re: Escalations - doesn't pick hostrgoup name

Post by airw »

Thanks tgriep.
That's what I though. However when I remove my sms contact (myself) from hosts.cfg I am not receiving any sms notifications at all.
The config still grabs escalations correctly. I assume the issue here is, it doesn't grab contacts properly, I might be mistaken though...

Code: Select all

Running pre-flight check on configuration data...
Checking service escalations...
   Checked 38 service escalations.
Checking host escalations...
   Checked 80 host escalations.
I don't see a logic here tbh...
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Escalations - doesn't pick hostrgoup name

Post by tgriep »

Is the router ""my_router" a member of the "routers" hostgroup?
Could you post the routers host group to the forum?
Be sure to check out our Knowledgebase for helpful articles and solutions!
airw
Posts: 10
Joined: Thu Jan 08, 2015 6:12 am

Re: Escalations - doesn't pick hostrgoup name

Post by airw »

~/.../hostgroups/routers-hg.cfg

Code: Select all

define hostgroup{
        hostgroup_name   routers
        alias                    routers-pw
        }
~/.../hostgroups/servers-hg.cfg

Code: Select all

define hostgroup{
        hostgroup_name   servers
        alias                    servers-pw
        }
Hostgroups should be fine.
I know it because when I add 'servers to my escalations I can see they are grabbed by pre-flight check:

Code: Select all

Running pre-flight check on configuration data...
Checking service escalations...
   Checked 38 service escalations.
Checking host escalations...
[b]   Checked 160 host escalations.[/b]
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Escalations - doesn't pick hostrgoup name

Post by tgriep »

I setup a test to replicate it and it is working for me. The only difference is that I setup my host and contact as follows.

Code: Select all

define host {
	host_name			Localtest
	use				xiwizard_generic_host
	address				127.0.0.1
	hostgroups			linux-servers
	initial_state			o
	notification_interval		30
	notification_period		24x7
	notification_options		d,u,r,
	notifications_enabled		1
	register			1
	}

define contact {
	contact_name                  		test
	host_notifications_enabled    		1
	service_notifications_enabled 		1
	host_notification_period      		24x7
	service_notification_period   		24x7
	host_notification_options     		d,r,
	service_notification_options  		u,c,
	host_notification_commands    		xi_host_notification_handler
	service_notification_commands 		xi_service_notification_handler
	email                         		test@test.com
	}

The only thing I can think of is that you don't have notifications enabled in your host template and your contact. Check those and see if they are setup correctly.
Be sure to check out our Knowledgebase for helpful articles and solutions!
airw
Posts: 10
Joined: Thu Jan 08, 2015 6:12 am

Re: Escalations - doesn't pick hostrgoup name

Post by airw »

Notifications are enabled.
I receive e-mails just fine.
It's escalations (which are sent via sms) that are not working.
Thanks for the effort.
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Escalations - doesn't pick hostrgoup name

Post by tgriep »

Does the escalations work using email and not SMS?
Be sure to check out our Knowledgebase for helpful articles and solutions!
airw
Posts: 10
Joined: Thu Jan 08, 2015 6:12 am

Re: Escalations - doesn't pick hostrgoup name

Post by airw »

Found a solution.

In hostescalation.cfg

Code: Select all

first_notification           1
Changed that value to 0 and it did a trick.
Not 100% sure here what it does but I believe it escalates that immediately. Thought "1" would do it.
Thanks tgriep.

I have a similar problem now with service escalation, not picking hostgroup_name, and sending a service escalation for all hosts. The fix I applied for host escalation does not work here. But I'll probably create a separate thread for that.
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Escalations - doesn't pick hostrgoup name

Post by tgriep »

Glad you have it working now.
It could be because of the notification_interval in your hosts template is set to 0.

Here is a description of the first_notification directive.
first_notification: This directive is a number that identifies the first notification for which this escalation is effective. For instance, if you set this value to 3, this escalation will only be used if the service is in a non-OK state long enough for a third notification to go out.

Shall I close the post?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked