Page 1 of 2

Inheritance doesn't seem to be working for config templates

PostPosted: Fri Aug 10, 2018 2:56 pm
by jlom
Inheritance doesn't seem to be working for my nagios core configs. I'm migrating from an old host to a new host which i've done before

I try to start nagios and it yells at me that
Code: Select all
max_check_attempts
isn't set


Long story short, Here are some clips from my configs.

from nagios.cfg
cfg_file=/etc/nagios/objects/linux.ctx.cfg
cfg_file=/etc/nagios/objects/hosts.cfg
cfg_dir=/etc/nagios/objects/services

From hosts.cfg
Code: Select all
define host {
host_name testbox1
use systems-host
notification_interval 1440
contact_groups systems
notification_period critical
}



From linux.ctg.cfg
Code: Select all
define host {
name systems-host
notifications_enabled 1
flap_detection_enabled 1
#failure_prediction_enabled 1
retain_status_information 1
retain_nonstatus_information 1
max_check_attempts 2
check_interval 3
check_period critical
check_command check_local!ping!
register 0
}



This works great on the old host, nagios 3 but the new nagios 4 host isn't not working. If i add
Code: Select all
max_check_attempts 2
directly to the host and don't use the template it works fine but then makes the configs messy. If i add the template to the same file as the hosts it still doesn't even inherit the values then either.

any ideas? I'm scratching my head on this one.

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Fri Aug 10, 2018 4:46 pm
by npolovenko
Hello, @jlom.
Please run the config verification command and show us the error message.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 5:44 am
by jlom
npolovenko wrote:Hello, @jlom.
Please run the config verification command and show us the error message.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg



Code: Select all
Error: Empty value for contact_groups (config file '/etc/nagios/objects/services/grants.cfg', starting on line 19)
Error: Could not add object property in file '/etc/nagios/objects/services/grants.cfg' on line 25.
Error: Invalid max_check_attempts value for host 'testhost1'
Error: Could not register host (config file '/etc/nagios/objects/hosts.cfg', starting on line 1391)
   Error processing object config files!



edited the hostnames but these are the errors.

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 1:31 pm
by scottwilkerson
please share your current config for testhost1

Also, you need to fix the error of an empty value for contact_groups on the grants.cfg

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 2:01 pm
by jlom
Code: Select all
define host {
host_name testhost1
use systems-host
notification_interval 1440
contact_groups systems
notification_period critical
}



The contacts fix is something I've already figured but have yet to implement.

This host definition is configured to use
Code: Select all
"systems-host"
as the template which defines the
Code: Select all
max_check_attempts

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 2:16 pm
by jlom
I'm working off of this doc.

https://assets.nagios.com/downloads/nag ... tance.html

just wondering what i could be missing.

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 2:54 pm
by scottwilkerson
can you show the host configuration for for the host that starts on line 1391 of hosts.cfg

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 3:18 pm
by jlom
Code: Select all
define host {
host_name testbox1
contacts unix-pager
use systems-host
notification_interval 15
contact_groups systems-mailer
notification_period critical
}

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 3:19 pm
by jlom
I've ensured the files are owned by nagios
I've ensured the names are not misspelled and syntax is correct.
All config files are called out in nagios.cfg

Re: Inheritance doesn't seem to be working for config templa

PostPosted: Mon Aug 13, 2018 4:40 pm
by scottwilkerson
You don't by chance have multiple systems-host templates in your configs do you?