Issue excluding hostgroup member from service

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.
Locked
justinpopa
Posts: 3
Joined: Fri Feb 26, 2016 6:28 pm

Issue excluding hostgroup member from service

Post 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?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Issue excluding hostgroup member from service

Post 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"
}
Former Nagios Employee
justinpopa
Posts: 3
Joined: Fri Feb 26, 2016 6:28 pm

Re: Issue excluding hostgroup member from service

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Issue excluding hostgroup member from service

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
justinpopa
Posts: 3
Joined: Fri Feb 26, 2016 6:28 pm

Re: Issue excluding hostgroup member from service

Post by justinpopa »

Go for it.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Issue excluding hostgroup member from service

Post by rkennedy »

Closing this one out, feel free to make a new thread if you ever need any assistance in the future.
Former Nagios Employee
Locked