Nagios - Define as service for all the members of a group *except* some hosts?

Solution 1:

Use the host_name directive in the service definition with an exclamation before the name of the host. For example:

define service{
        service_description     CPU Stats
        servicegroups   sysres
        use             generic
        hostgroup_name  linux
        host_name       !server1
        check_command   check_iostat
}

Solution 2:

define service{
    service_name myservice
    hostgroup_name mygroup
    host_name !dontmonitorthis,!orthis
}

Solution 3:

Sorry if this thread is old, but I had resolved this exact problem as @arun had implementing the solution.

I haven't found why exactly yet, nor how to re-enable them, but having regular expressions enabled in my nagios.cfg stopped "!" (host/group negation) working for me.

Once I disabled it (set use_regexp_matching=0 in nagios.cfg), I was able to use them fine.

(nagios 3.3.1, x86_64)