how to configure hostgroup inheritance in Nagios 4.4.5 and display it on Nagios webpage

40 Views Asked by At

Suppose I have 8 linux servers, among them 4 are db servers and 4 are app servers. I create a linux hostgroup and added 2 inheritance hostgroups linux app servers and linux db servers. But when I reload nagios.cfg and browse nagios web page all the 8 servers are showing under linux hostgroup. How can I display the inheritance hostgroups under linux hostgroup?

I tried the above process by defining like

define hostgroup { hostgroup_name Linux alias Linux Server hostgroup_member Linux DB Server, Linux APP server }

define hostgroup { hostgroup_name Linux DB Server alias Linux DB Server }

define hostgroup { hostgroup_name Linux APP Server alias Linux APP Server }

But all the APP and DB servers are shown in only Linux hostgroup and no mention of inherited hostgroup in the list.

I want to display on the nagios web page Like:

Linux (main hostgroup) Linux DB Servers (inherited hostgroup) DB Server 1 DB Server 2 DB Server 3 DB Server 4

    Linux APP Servers (inherited hostgroup)
      APP Server 1
      APP Server 2
      APP Server 3
      APP Server 4
1

There are 1 best solutions below

2
pzkpfw On

None of your hostgroups have any members. Based on your description as I understand it, I would expect to see configuration that looks something like:

define hostgroup { 
  hostgroup_name Linux APP Server
  alias Linux APP Server
  members app1,app2,app3,app4
}

define hostgroup { 
  hostgroup_name Linux DB Server
  alias Linux APP Server
  members db1,db2,db3,db4
}

define hostgroup { 
  hostgroup_name Linux
  alias Linux Server
  hostgroup_member Linux DB Server,Linux APP server
}

I assume you've configured host group membership on the hosts themselves, but since you don't include this configuration it's not easy to help you.

edit I might have misunderstood your question

But when I reload nagios.cfg and browse nagios web page all the 8 servers are showing under linux hostgroup

This is expected behavior. hostgroup_member only includes whatever is in that hostgroup in that host group. It's not a way to include "hostgroups in hostgroups", it's a way to include hosts from a hostgroup in another hostgroup easily.

For more information see the documentation, specifically:

hostgroup_members: This optional directive can be used to include hosts from other "sub" host groups in this host group. Specify a comma-delimited list of short names of other host groups whose members should be included in this group.

It's a common misconception that host groups are objects themselves, when they are in fact just "aliases" for groups of hosts. They do nothing except make it easier for you, so that you can write app_servers instead of app1,app2,app3,app4,app5(...).