List of host groups not updating on icinga2 reload


I have a script that automatically generates host and hostgroup definitons based on our configuration management system. This runs every 30 minutes on a cronjob, and runs systemctl reload icinga2 on completion. It seems that only the manually written hostgroups (in another file) are shown in Icingaweb2 - even though the config check says that 39 have been instantiated?
As far as I can tell the automatically generated files have valid configuration by running icinga2 daemon -C - and these files are located in the same directory as the manually written ones in zones.d/ with a HA setup.

[2020-02-27 10:13:42 +0000] information/ConfigItem: Instantiated 39 HostGroups.
[2020-02-27 10:13:42 +0000] information/ConfigItem: Instantiated 1215 Hosts.

I’ve checked with different accounts and browsers and only these two show.

What could be causing this behaviour? Restarting (systemctl restart icinga2) the daemon shows the host groups - but I’d rather not restart every 30 mins.

I’ve looked in the icinga IDO database and can see the hostgroups there (well - these and much older ones that no longer exist).




Did you cross check that the objects exist in icinga2 with icinga2 object list --type hostgroup?
Btw i would change your script to reload icinga2 only if there is a config change to the prior run.



Thanks for your reply - the object I am looking for does not exist in icinga2 object list --type hostgroup - but Icinga has been reloaded at least once (and config check passes OK) so what does this mean?,
I’ll look into making that change,



either there is no host attached to that host groups or your apply rule for the hostgroup does not match any host.


Hi, thanks. I’ve just experienced the same problem again. The object DOES exist this time in icinga2 object list --type hostgroup but still isn’t showing in the web interface?

The apply rules should be working… for example here’s a host that should be in a host group that isn’t showing:

object Host "" {
import "mysite/mypersonality"
address = ""
vars.remote_client = ""
vars.shortname = "host"
vars.archetype = "mysite"
vars.personality = "mypersonality"
vars.notification["mail"]  += { users = [ "user" ] }

And then the HostGroup definition:

object HostGroup "mysite/mypersonality" {
display_name = "mypersonality (mysite)"
assign where host.vars.personality == "mypersonality" && host.vars.archetype == "mysite"

Finally the HostGroup object:

Object 'mysite/mypersonality' of type 'HostGroup':
% declared in '/etc/icinga2/aq-hostgroups.conf', lines 356:1-356:38
* __name = "mysite/mypersonality"
* action_url = ""
* display_name = "mypersonality (mysite)"
  % = modified in '/etc/icinga2/aq-hostgroups.conf', lines 357:3-357:40
* groups = null
* name = "mysite/mypersonality"
* notes = ""
* notes_url = ""
* package = "_etc"
* source_location
* first_column = 1
* first_line = 356
* last_column = 38
* last_line = 356
* path = "/etc/icinga2/aq-hostgroups.conf"
* templates = [ "mysite/mypersonality" ]
  % = modified in '/etc/icinga2/aq-hostgroups.conf', lines 356:1-356:38
* type = "HostGroup"
* vars = null
* zone = ""

I can also add the Object Host definition too if required. It shows the correct archetype and personality variables set.