Page 1 of 1

Proper way to exclude service from sending notifications.

Posted: Wed Nov 13, 2019 9:53 am
by tman77
I have a service check for rabbitmq that checks the queue length.

Its currently failing on a few servers, due to the version of a python module installed on the remote host.
However, these servers are due to be upgraded in a couple of weeks, so for now I'd just like to prevent the unknown alerts for this service from being sent. Below are the service and service escalation definitions.

I tried to just exclude a couple of the affected hosts in the service definition.

However, when I do that, I get back the following error...
Error: Could not find a service matching host name 'hosta' and description 'Service: Rabbitmq Queue Count' (config file '/usr/local/nagios/etc/objects/service_escalations.cfg'

Code: Select all

define service {
        use                   generic-service
        hostgroup_name        web_servers_vpc
        host_name             !hosta, !hostb
        service_description   Service: Rabbitmq Queue Count
        check_command         check_nrpe_1arg!check_rabbitmq_queue_count
}

define serviceescalation {
        hostgroup_name         web_servers_vpc
        service_description    Service: Rabbitmq Queue Count
        contact_groups         Admins
        first_notification     1
        last_notification      0
        notification_interval  60
}
Is there a simple way to exclude a host in the config files so a particular service wont be checked?

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 10:42 am
by scottwilkerson
I would return the config to how it was, then in the UI got to the service status detail page for
hosta -> Service: Rabbitmq Queue Count

Under "Service Commands" section click "Disable active checks of this service"

do the same for
hostb -> Service: Rabbitmq Queue Count

When these are resolved, go back to the same pages and click "Enable active checks of this service"

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 11:39 am
by tman77
Thanks Scott.

I thought of doing exactly that, but I wanted to understand if there was a way of being able to accomplish same/similar via adjusting the configs.

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 11:44 am
by scottwilkerson
There would be if you didn't have the hostgroup assigned to the service and the same with the escalation.

When you Negated to hosts on the service config it actually removed the services completely, the problem is that you didn't negate them in the escalation ans as such the escalation is expanding the hostgroup/service combination and it included the 2 host/service combinations that no longer exist because you removed them from the service definition.

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 12:59 pm
by tman77
Oh I see, so, could I either...
remove the hostgroup designation and just specify hosts, or also negate those hosts in the service escalation, and it wont exapnd them?

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 1:02 pm
by tman77
Yep, negating specific hosts in both service definition and service_escalations definition worked. That was easy, I should have thought of that from start, thanks for pointing that out.

Re: Proper way to exclude service from sending notifications

Posted: Wed Nov 13, 2019 1:02 pm
by scottwilkerson
tman77 wrote:Yep, negating specific hosts in both service definition and service_escalations definition worked. That was easy, I should have thought of that from start, thanks for pointing that out.
Glad it is resolved!

Locking thread