"Assign where" in hostgroup does not work

(Christian Weber) #1

Hi,

I am trying to “fill” a hostgroup with amother one. I thought this is quite easy because it works with custom variables. It looks like that:
grafik

What am I doing wrong?

Thanks and best regards
Christian

(Christian Weber) #2

Some additional explanation:
I want to have one histgroup in another hostgroup wich doesn’t work. The same habbens if I want to “pin” a template to a workgroup e.g. host.templates. Neither of that works, the new hostgroup always is empty.

#3

I’m not sure if the following applies in this situation:
Some things are resolved at runtime, not at “compile” time, when the objects are checked for validity.

Looking at the documentation I don’t see an example refering to host groups.

(Christian Weber) #4

I dind´t find anything about host.groups and host.templates in the documentation of host groups.

Is there any best practice for nesting host groups if that really doesn’t work?

(Kai) #5

Your syntax “host.groups = nameofgroup” in your initial post looks wrong. I think you need to use “contains” instead of “=”. Because “host.groups” is an array…

1 Like
(Christian Weber) #6

Good Point, Kai. I just tested it, but it still doesn´t work with hostgroups in hostgroups. But it works with templates. And that ist a big step for me. Thanks!

Maybe anybody could confirm that nested hostgroups don´t work?

Regards
Christian

(Arethusa) #7

Hello, I’m not sure that can help you cause I use only CLI, but to create my group “data” I do on a group.conf:

object HostGroup "data" {
  display_name = "data"

  assign where host.address == "192.168.1.11"
  assign where host.address == "192.168.1.12"
  assign where host.address == "192.168.1.13"

}

Then, when I whant to apply à service to this group, I do:

apply Service "Data Partition" {
  import "snmpv3-tmpl"

  vars.snmpv3_label = "Data Usage"
  vars.snmpv3_units = "%"

  vars.snmpv3_oid = "1.3.6.1.4.1.2021.922.4.1.2.4.100.97.116.97.1 "

  vars.snmpv3_warn = 85
  vars.snmpv3_crit = 95

 assign where "data" in host.groups
}

In my case I use snmpv3, but, IMO, the most importante part for you is:

To assign host on group:

assign where host.address == "192.168.1.13"

To assign group for service:

assign where "data" in host.groups

(Christian Weber) #8

Hi Arethusa,

thanks for your input. I did not yet work with the director cli but I will try and come back.

Thanks.

Christian