Page 1 of 1

Filter Service notifications

Posted: Thu Jan 21, 2016 7:38 am
by goldmund84
Hello,
I would like to do some limitations on contact notification.
For example, I have Service "CPU Load" and 20 Hosts added to this Service. I've added Contact, say Admin-1, to this Service, but I want to send a notification to the Contact Admin-1 only if the alert is on the Host-1 and Host-2 (but not Host-3, etc). At the moment, Admin-1 will receive notification from each of 20 Hosts.
So is it possible, to limit notifications to certain Hosts?
I know that I can do separate Service check "CPU Load" and add to it only hosts I want, but that is not convenient.

Thanks.

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 9:37 am
by rkennedy
Just to clarify - are you looking to make it send a notification if the CPU Usage is critical on both host 1 & host 2 at the same time?

Yes, this is possible if so. It's called BPI, which allows grouping of services. Check out this document - https://assets.nagios.com/downloads/nag ... _Addon.pdf

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 9:54 am
by goldmund84
>>Just to clarify - are you looking to make it send a notification if the CPU Usage is critical on both host 1 & host 2 at the same time?
No, just if one of the hosts has an issue.

Thanks, I'll try the BPI solution.

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 10:06 am
by hsmith
Let us know how BPI works out for you.

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 10:22 am
by goldmund84
It seems that BPI is something used for other purposes.

My situation is as following. We have a certain number of servers in our Nagios XI, they have similar Services (such as CPU Load, Memory Usage, etc).
We have one Service and several hosts added to it (with the button "Manage Hosts").

Now I'm adding a host that will be monitored by other guys (not from our company, with their own Contact e-mails). These guys will not have access to Nagios web-interface, but will just receive e-mail alerts.
The new Linux host is much similar to our existing hosts. I don't want to create new Services and tried to add this host to our existing services (with the button "Manage Hosts"). But if I add Contact e-mail of new guys to the Service (in Alert Settings -> Manage Contacts), they will receive alerts not only from the new host, but from my old hosts, and that is a problem. I have to limit in some way that they will receive only alerts for their hosts, but not ours.

Is it possible? Or it's better just to create separate Services?

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 2:07 pm
by rkennedy
Ah - I was a bit confused in your first post.

Are you using service groups to inherit who is notified? You should be able to just remove who is notified on a per service basis. Can you post one of your service definitions as an example?

Re: Filter Service notifications

Posted: Thu Jan 21, 2016 2:25 pm
by lmiltchev
You could use something like this:

Code: Select all

define host {
	host_name			HostA
	contact_groups		admins
	...		
	}
	
define host {
	host_name			HostB	
	contact_groups		users	
	...
	}
	
define service {
	host_name			HostA,HostB
	service_description		myservice
	...
	}
Contacts, members of the "admins" contact group will receive notifications about "myservice" on HostA, and "users" will receive notifications about "myservice" on HostB, provided you didn't specify any contacts explicitly on a service level.

Please, review our documentation on object inheritance (implied inheritance section):

https://assets.nagios.com/downloads/nag ... tance.html

Re: Filter Service notifications

Posted: Fri Jan 22, 2016 4:09 am
by goldmund84
You could use something like this:
While using your example, I receive the following behavior: If something happens with Host, the appropriate contact receives a notification. But if Service changes its state from OK to any other, nobody receives any notification, until the contact or contact group is added to service definition or template. I should add 'contact_groups' inside service definition in order to receive notification.

The example of my service:

Code: Select all

define service {
        host_name                       colada,cortana,europe1,europe2,helpdesk,mail.com,mars.com,Mercury1,Mercury2,ns.com,pluto
        service_description             CPU Load
        use                            example-support-service
        check_command                   check_snmp_linux_load!-f -w 70 -c 80!!!!!!!
        register                        1
        }

define service {
       name                                     example-support-service
       is_volatile                              0
       max_check_attempts                       3
       check_interval                           10
       retry_interval                           2
       active_checks_enabled                    1
       passive_checks_enabled                   1
       check_period                             24x7
       parallelize_check                        1
       obsess_over_service                      1
       check_freshness                          0
       event_handler_enabled                    1
       flap_detection_enabled                   1
       process_perf_data                        1
       retain_status_information                1
       retain_nonstatus_information             1
       notification_interval                    20
       notification_period                      24x7
       notification_options                     w,c,u,r,
       notifications_enabled                    1
       contact_groups                           admins
       register                                 0

}

Re: Filter Service notifications

Posted: Fri Jan 22, 2016 12:48 pm
by rkennedy
Yes, that will add notifications for the services.