first look into apply rules and their assign where expressions. You can for example check whether a service is in a specific group.
assign where "sg1" in service.groups
In order to not use so much service groups, but existing host groups - e.g. for nrpe hosts, you could also just use
object Host "..." {
...
vars.agent_type = "nrpe"
}
object HostGroup "nrpe-agents" {
assign where host.vars.agent_type == "nrpe"
}
apply Service "nrpe-disk" {
...
assign where "nrpe-agents" in host.groups
}
Such apply rules can be used for Dependency objects as well, rendering the child object automatically. AFAIK that’s what dependent_servicegroup_name is, I always had to bang my head against this description never knowing whether this is now the child or parent in the relation. The naming schema is from one of my designs for Dependencies.
apply Dependency "nrpe-agents" to Service {
...
//Omit the parent_host_name to apply the dependency for services on the same host
parent_service_name = "nrpe-health"
assign where "nrpe-agents" in host.groups
ignore where service.name == "nrpe-health" //don't apply this for the health check itself
}