Page 1 of 2

Notification Problems

Posted: Wed Oct 04, 2017 11:26 am
by Chapzele
Hi, I am experiencing some very odd behavior with notifications, and I can't tell if it is a bug or just something to do with my implementation. I have the following two services configured:

Code: Select all

define service{
        hostgroup_name                  Windows_Servers
        service_description             CPU
        _SERVICE_ID                     47
        is_volatile                     1
        check_command                   check_cpu!2c!public!90!80
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        check_period                    24x7
        notification_interval           0
        notification_period             24x7
        notification_options            w,c,r
        notifications_enabled           1
        contact_groups                  Group1
}

define service{
        host_name                       SERVER1
        service_description             CPU-2
        _SERVICE_ID                     108
        check_command                   check_cpu!2c!public!90!80
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        check_period                    24x7
        notification_interval           0
        first_notification_delay        0
        notification_period             24x7
        notification_options            w,c,r
	notifications_enabled           1
	contacts                        User1
}
These are effectively doing to the same thing, however one is targeting a host group (Windows_Servers), and notifies a contact group (Group1), while the other is only targeting one host (Server 1) and notifying one user. (User1) The host "SERVER1" is also in the host group "Windows_Servers".

What I am finding is that when the host has a CPU spike that would trigger both of these checks, it notifies everybody. That is the, Group1 and User1 both receive the alerts for CPU and CPU-2.

Is this some sort of limitation of having the same check command on a host twice, or should I be able to keep things separate?

In another strange incident, I just had the check go to critical and send alerts to Group1 every minute until it was resolved, despite the command clearing having notification_interval set to 0.

Thanks for any help, I have tried everything I can to make this as simple as possible and it still doesn't seem to do what I expect it to!

Re: Notification Problems

Posted: Wed Oct 04, 2017 1:45 pm
by kyang
Are you trying to get separate notifications for Group1 and User1? Or the same notification for both?

The CPU service from the SERVER1 host is the same as the one in the host group? That means the SERVER1 host is in the Windows_Servers host group?

If you have the same exact service twice with a host_name SERVER1 that is in the Windows_Servers host group, but the only thing different is contacts.
Then I would think it would send to both contacts if the CPU is spiking since it's the same exact host and service check.

So if you could tell us what you expect it to do, that would be very helpful. I'm not really sure what you are trying to accomplish?

Re: Notification Problems

Posted: Wed Oct 04, 2017 2:51 pm
by Chapzele
Sorry I am not sure I explained it clearly. Currently I have a host group for Windows Servers, and that has all the different services assigned to it. This is so that I can add a new Windows server to the host group and automatically have it pick up all of the various services without assigning manually.

The first service I posted above specifically is a CPU check, and that is configured to contact a group, so several technicians get emails when any host in the group has a CPU issue.

What I would also like to do is have a separate CPU service that only checks one of the servers in the group, and contacts a specific person when it fails. If I just add the user to the contacts for the first service, they will get alerts for all of the hosts in the group.

So to try and achieve this I created a second "CPU" service, CPU-2, and assigned it to the single host. This service is set only to contact that individual user.

What I believe I have is two almost identical services, in that they call the same commands with the same parameters, however where one is applied to a host group and alerts a contact group, the others is applied to a single host and alerts a single contact.

The issue I am having is that "CPU" is alerting both the contact group assigned, and also the individual user, even though that user is not set up to receive alerts for that service. The same is happening with "CPU-2" alerting the group.

I hope that is a bit clearer, if not let me know! And thanks for taking a look.

Re: Notification Problems

Posted: Thu Oct 05, 2017 9:57 am
by kyang
Could I see how your hostgroups and contacts are set up?

Re: Notification Problems

Posted: Thu Oct 05, 2017 10:10 am
by Chapzele
Host group:

Code: Select all

define hostgroup{
        hostgroup_name                  Windows_Servers
        alias                           All windows servers
}
One of the hosts:

Code: Select all

define host{
        host_name                               WEB4
        alias                           WEB4
        address                         <<removed>>
        _HOST_ID                                26
        _SNMPCOMMUNITY                  public
        _SNMPVERSION                    2c
        hostgroups                      Windows_Servers,Web_Servers
        max_check_attempts                      1
        check_interval                  1
        check_period                    24x7
        notification_options            d,u,r
        notifications_enabled           0
}
Single Contact

Code: Select all

define contact{
        contact_name                    <<removed>>
        alias                           <<removed>>
        host_notification_period                24x7
        service_notification_period             24x7
        host_notification_options               n
        service_notification_options    w,c,r
        host_notification_commands              host-notify-by-email
        service_notification_commands   notify-by-email
        email                           <<removed>>
        host_notifications_enabled              1
        service_notifications_enabled   1
}
All other contacts are set up the same, contact group:

Code: Select all

define contactgroup{
        contactgroup_name     Tech_Services
        alias                           Tech Services
        members                         <<removed>>
}
So all of the hosts in the host group have a service that runs and should alert the contact group. There are then some individual hosts which as well as being in the host group have a separate service that runs, using the came CPU command, and should only alert a single contact. The issue we are having is that everyone the in contact group gets alerts for both services, and the single contact also gets alerts for both services.

Re: Notification Problems

Posted: Thu Oct 05, 2017 10:13 am
by Chapzele
If it helps, this is the host group service:

Code: Select all

define service{
        hostgroup_name                  Windows_Servers
        service_description             CPU
        _SERVICE_ID                     47
        check_command                   check_cpu!2c!public!90!80
        max_check_attempts                      3
        normal_check_interval           1
        retry_check_interval            1
        check_period                    24x7
        notification_interval           0
        first_notification_delay                0
        notification_period             24x7
        notification_options            w,c,r
        notifications_enabled           1
        contact_groups                  Tech_Services
}
And this is the individual service:

Code: Select all

define service{
        host_name                           <<removed, some of the servers also in the host group>>
        service_description             CPU-2
        _SERVICE_ID                     108
        check_command                   check_cpu!2c!public!90!80
        max_check_attempts                      3
        normal_check_interval           1
        retry_check_interval            1
        check_period                    24x7
        notification_interval           0
        first_notification_delay                0
        notification_period             24x7
        notification_options            w,c,r
        notifications_enabled           1
        contacts                               <<Removed, contact listed in post above>>
}


Re: Notification Problems

Posted: Fri Oct 06, 2017 10:13 am
by scottwilkerson
What you need to do is in the service where you are adding this

Code: Select all

hostgroup_name                  Windows_Servers
You need to NEGATE the host names with ! that you are going to setup on their own services, so if it was SERVER1, SERVER2, SERVER3 you would use

Code: Select all

host_name                           !SERVER1, !SERVER2, !SERVER3
See Excluding Hosts section here
https://assets.nagios.com/downloads/nag ... ricks.html

Re: Notification Problems

Posted: Fri Oct 06, 2017 10:23 am
by Chapzele
If I exclude those hosts from the host group service, does that mean I will need to add the contact group to the individual service as well? Otherwise the contact group in the host group service won't get any alerts for those servers.

The reason I didn't want to exclude those hosts from the host group service is that I will then lose the history from that service.

Re: Notification Problems

Posted: Fri Oct 06, 2017 11:02 am
by scottwilkerson
Chapzele wrote:If I exclude those hosts from the host group service, does that mean I will need to add the contact group to the individual service as well? Otherwise the contact group in the host group service won't get any alerts for those servers.
[/quoteye]
Yes, you would need to add the contact group to the new service you want to be notified
Chapzele wrote:The reason I didn't want to exclude those hosts from the host group service is that I will then lose the history from that service.
You cannot have it both ways. You can't make the change to have different settings for the services and not get notified for these services because you leave the service created.

Re: Notification Problems

Posted: Tue Oct 10, 2017 8:54 am
by Chapzele
Ok thanks for the confirmation, it looks like I won't be able to do what I wanted. It will be easier to tell them they just need to get all the CPU alerts!