Page 1 of 2

service override via nested hostgroup - only last host works

Posted: Fri May 15, 2015 6:09 pm
by stucky
Nagios gurus

This one has had me speechless for a few days but I finally figured out how to reliably produce the problem.
I have an uptime service tied to a hg1 and another uptime service with a different contact group tied to hg2 nested in hg1.
When I add one member to hg2 everything works as expected - the uptime service gets overwritten from the one inherited from hg1 to the overwrite one. However, as soon as I add new hosts to hg2 all members loose the overwrite again except the LAST one. At any time only the last group member has the overwrite.
I looks and feels like nagios only ever evaluates the last member of a nested hg when looking at overwrites.

This can't be desired. Any insight ?

Re: service override via nested hostgroup - only last host w

Posted: Mon May 18, 2015 12:04 am
by Box293
You need to define the hostgroups with object inheritance.

In the service, on the Common Settings tab
Click the "Manage Hostgroups" button
For the "Hostgroup Options" radio, select +
Click Close

For the contact groups, on the Alert Settings tab
Click the "Manage Contactgroups" button
For the "Contactgroup Options" radio, select +
Click Close

Here's some reading material:
http://nagios.sourceforge.net/docs/3_0/ ... tance.html

Does this help?

Re: service override via nested hostgroup - only last host w

Posted: Mon May 18, 2015 12:03 pm
by stucky
Box

Thanks for the reply but I had already tried that. It doesn't make any difference. The behaviour is the same. To be honest I don't follow the logic here.
It appears that object inheritance is already turned on even when I associate the service to the hg in a "standard" manner.
I can tell in multiple ways:

1. If I rename the service to make it distinct then both hosts show both the inherited as well as the new service.
2. The hosts have all the usual checks associated with them that can only have been inherited from higher up so inheritance seems to work.

Furthermore, this works perfectly well as long as the nested hg only contains one member. If I needed the + here then this should not work at all no matter how many members are in the group, right ? It's seems to only be the service overwrite that doesn't. If anything I'd expect the opposite behaviour if there was a problem with inheritance.
I'd think that the lowest nested hg would always win over the inherited stuff so I should see the overwritten service rather than the inherited one. The fact that I still see the inherited service shows that inheritance works, no ?

Re: service override via nested hostgroup - only last host w

Posted: Mon May 18, 2015 12:24 pm
by stucky
One more thought. The + simply means that rather than overwriting the inherited values I want to add them to the local values. I understand that but that does not govern whether or not objects are inherited as far as I understand.

Re: service override via nested hostgroup - only last host w

Posted: Mon May 18, 2015 1:19 pm
by jdalrymple
I think you found a bug.

Code: Select all

define service {
       name                                     simple-service
       service_description                      simple-service
       hostgroup_name                           simple-hostgroup
       check_command                            check_dummy!0
       max_check_attempts                       1
       check_interval                           1
       check_period                             24x7
       retry_interval                           1
       notification_interval                    60
       notification_period                      24x7
       contacts                                 nagiosadmin
       register                                 1
}

define service {
       name                                     simple-service-nest
       service_description                      simple-service
       hostgroup_name                           simple-hostgroup-nest
       check_command                            check_dummy!1
       max_check_attempts                       1
       check_interval                           1
       check_period                             24x7
       retry_interval                           1
       notification_interval                    60
       notification_period                      24x7
       contacts                                 foo
       register                                 1
}

define hostgroup {
       hostgroup_name                           simple-hostgroup
       alias                                    simple-hostgroup
       members                                  simple-host-a
       hostgroup_members                        simple-hostgroup-nest
}

define hostgroup {
       hostgroup_name                           simple-hostgroup-nest
       alias                                    simple-hostgroup-nest
       members                                  simple-host-c, simple-host-b
}
Or at a minimum we deserve an explanation in the logic. I'll post an internal bug, but also leave the topic open for others to chime in. We'll see what comes of it.

Re: service override via nested hostgroup - only last host w

Posted: Mon May 18, 2015 1:44 pm
by stucky
Thanks jda

This baffles me I have to admit. Seems to be the most basic use case for service overwrite. Has nobody done this before ?
Am I using nagios in a weird way ?

Re: service override via nested hostgroup - only last host w

Posted: Tue May 19, 2015 11:50 am
by jdalrymple
I wouldn't say Service Overwrite is the fundamental reason to use nested hostgroups...

All Windows servers have a C drive

Some Windows servers have IIS service and an I drive, Some have MSSQL and an L drive.

Some MSSQL Server servers have prod timeperiods, some have non-prod timeperiods.


I think most people use nestings to complement, not overwrite.

Re: service override via nested hostgroup - only last host w

Posted: Tue May 19, 2015 12:22 pm
by stucky
jda

Im not sure I agree.What about the following common problems:

1. Normally all alerts for LOAD go to the SA group but for a subset of systems it needs to go to another contact group as well so I need to overwrite check load.
2. Normally LOAD is 30,20,10 but on a subset of systems it needs to be much higher as they normally have a high load so you need to overwrite the check load to let's say 60,50,40.

To me that is one of the purposes of nesting hostgroups. Otherwise I find myself in a mess of groups and exclusions. Now I have to take these subsystems out of the regular groups and define everything again just for one slightly different service notification. Am I looking at this wrong ?

Re: service override via nested hostgroup - only last host w

Posted: Tue May 19, 2015 12:32 pm
by jdalrymple
Your use case is fine - and that's why I filed the bug. I agree with you that the behavior should predictably overwrite.

I was simply stating that what we see in most environments is not to overwrite the services, but just have separate nested hostgroups based upon 2 separate use cases.. You could achieve the same results in both of your situation by having 3 hostgroups instead of 2, and not defining your service on the top group.

Nothing is wrong with the way you want to do it and it's ultimately a shorter path to the same goal.

Re: service override via nested hostgroup - only last host w

Posted: Tue May 19, 2015 1:08 pm
by stucky
Thx jda
This is holding me up quite a bit. Could you please update this thread as soon as you have a confirmation and possibly ETA for a fix ?