Page 1 of 1

register variable inheritance

Posted: Thu Feb 13, 2014 8:27 pm
by robiny
Greetings,

I'm upgrading from Nagios Core 3.4.4 to Nagios Core 4.0.2. The install itself went fine, but when I attempt to start, I am getting this error about my template.cfg file:

Error: Service has no hosts and/or service_description

Here's part of my template.cfg:

Code: Select all

define service {
    name                    base-service
    use                     generic-service
    contact_groups          OPS
    notification_interval   60              ; in minutes
    register                0               ; don't register - this is just a template
    check_period            24x7
    notification_period     24x7
}

define service {
    name                    1-min-int
    use                     base-service
    normal_check_interval   1   
    retry_check_interval    1   
    max_check_attempts      2   
    notification_options    w,u,c,r
}
The service 1-min-int appears to no longer be inheriting the register variable from base-service. Looking at both the Nagios 3 and 4 documentation, they spell out that this variable is not inherited:
This variable is NOT inherited; every (partial) object definition used as a template must explicitly set the register directive to be 0. This prevents the need to override an inherited register directive with a value of 1 for every object that should be registered.
And indeed, when I add the register variable to all of my templates, Nagios does not error and starts.

Looking through the changelog, it doesn't make sense to me why the previous template.cfg was working with Nagios 3.4.4, as I'm not able to find any documentation on this.

Thoughts?

Thank you.

Re: register variable inheritance

Posted: Fri Feb 14, 2014 11:54 am
by abrist
robiny wrote:Looking through the changelog, it doesn't make sense to me why the previous template.cfg was working with Nagios 3.4.4, as I'm not able to find any documentation on this.

Thoughts?
I just talked to one of our core devs. Nothing was changed to core from 3.4.4 to 3.5/4.0 that altered the way "register" works. If "register" was inheritable, then all of your objects would have to include "register=1" or else they would inherit the template setting. As "register=1" is default, this would be problematic.

Maybe you had a rogue config somewhere, or maybe your configs were not parsing correctly? If it truly worked with 3.4.4 is was not WAI, and should not be relied upon. Just set "register=0" on all your templates as you have done.