Page 1 of 1

Issue excluding hostgroup member from service

Posted: Fri Feb 26, 2016 6:34 pm
by justinpopa
Hey there,

I'm having an issue excluding a hostgroup member from a service. I have the hostgroup and member of the hostgroup configured as follows:

Code: Select all

define hostgroup {
        hostgroup_name          windows-system
        alias                   Windows System
}

Code: Select all

define host {
        use             host-default
        host_name       dgr-servername
        alias           DGR-ServerName
        address         192.168.1.0
        hostgroups      windows-system
}
I have a service configured for that hostgroup as follows:

Code: Select all

define service {
        use                             service-default
        hostgroup_name                  windows-system
        service_description             ServiceName
        check_command                   check_snmp_win!"^ServiceName"
}
Up to this point everything is working as expected. I then attempted to exclude a specific member host of that hostgroup by adding the following to the service definition:

Code: Select all

        host_name                       !dgr-servername
Upon which I received the following error in the pre-flight check.

Error: Could not find a service matching host name 'dgr-servername' and description 'ServiceName' (config file '/usr/local/nagios/etc/services.d/windows-system.cfg', starting on line 62)
Error: Failed to expand same-host servicedependency services (config file '/usr/local/nagios/etc/services.d/windows-system.cfg', starting at line 62)

Where have I gone wrong in this configuration?

Re: Issue excluding hostgroup member from service

Posted: Mon Feb 29, 2016 10:38 am
by rkennedy
Can you post the full service definition for the one you're attempting to exclude? You should be able to use a [iicode]![/icode] when you define the hostgroup.

Per your example -

Code: Select all

define service {
        use                             service-default
        hostgroup_name                 !windows-system
        service_description             ServiceName
        check_command                   check_snmp_win!"^ServiceName"
}

Re: Issue excluding hostgroup member from service

Posted: Wed Mar 09, 2016 4:45 pm
by justinpopa
Sorry for the distinct lack of response on this. I posted the question and the next day I was pulled to another project temporarily.

I found the issue, and it's a dumb one. One part misconfiguration, one part failing to read the error output.

I had a service dependency assigned to the service that I was trying to exclude this hostgroup member from. Once I added the host_name !servername to the service dependency config, the config tested fine.

Re: Issue excluding hostgroup member from service

Posted: Wed Mar 09, 2016 5:43 pm
by lmiltchev
Thanks for the feedback, justinpopa! I am glad to hear that your issue has been resolved. Is it all right if we lock the thread?

Re: Issue excluding hostgroup member from service

Posted: Wed Mar 09, 2016 5:46 pm
by justinpopa
Go for it.

Re: Issue excluding hostgroup member from service

Posted: Thu Mar 10, 2016 10:32 am
by rkennedy
Closing this one out, feel free to make a new thread if you ever need any assistance in the future.