Is there a way to exclude specific hosts from a Nagios hostgroup?

I have a Nagios server which includes many hostgroups. One of these hostgroups include a server which I'd like to exclude from being checked for one specific Nagios Check but I want it to keep being a member of the hostgroup so it may get checked for all the other checks that the hostgroup is checked for. Is there an option of exclude or something like that which can help me achieve my goal? Thanks


Haven't yet tried it with hosts, but with hostgroups, prefixing with a ! works. I use this for running a different load check on busy servers:

define host {
    use         physical-host
    host_name   busy-host.example.com
    alias       busy-host.example.com
    address     10.43.16.1
    hostgroups  linux,centos,ldap,http,busy
}

define host {
    use           physical-host
    host_name     normal-host.example.com
    alias         narmal-host.example.com
    address       10.43.1.1
    hostgroups    linux,centos,dns,proxy,ldap,hp,http,puppetmaster
}

define service {
    use                   generic-service
    hostgroup_name        linux,!busy
    service_description   Load
    check_command         check_snmp_load
}

define service {
    use                   generic-service
    hostgroup_name        busy
    service_description   Load
    check_command         check_snmp_load_busy
}

Add the specific host with a ! prefix in the service definition. The service check below will apply to all hosts in agroup apart from ahost.

define service {
    hostgroup_name   agroup
    host_name       !ahost   
    service_description Shared NFS mount
    check_command check_nrpe!check_shared_mount
    use generic-service

}


You can create one or more hostgroup(s) for excluding things - add it/them to hosts where you want to exclude one or more checks - naming it something like ~no-ipv6 or ~no-ssl or whatever makes it pretty obvious what it's meant to do.

Apply the exclude hostgroup to the host(s) you want to exclude in addition to the normal one(s) it's a member of.

In the Service description, where the hostgroup name(s) that have that service applied are defined, use an ! (in this context, meaning "not") to exclude them.

So if you have a hostgroup "webservers", where some hosts can't do ssl, you might create another hostgroup "~no-ssl". In the services.cfg file, on the service definition that checks https, under hostgroup name, you would put webservers,!~no-ssl

The effect of this would be that all hosts in the hostgroup webservers are checked against SSL - but those that are also in hostgroup ~no-ssl won't have SSL checked. Handy!

If there are some checks you want ALL hosts to undergo, aside from a few, you can use *,!~exclusion

This abstraction is tremendously useful; even more so is using templates to assign (or exclude) a whole bunch of services to a type of host (which then means you can use the hostgroups definitions on each host simply for "extra" additional checks you want to run, or specific exclusions - i.e. template is the "norm", hostgroups are the exception(s)).