Inheritance doesn't seem to be working for config templates

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The SourceForge.net mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

Inheritance doesn't seem to be working for config templates

Postby jlom » Fri Aug 10, 2018 2:56 pm

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.
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby npolovenko » Fri Aug 10, 2018 4:46 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
npolovenko
Support Tech
 
Posts: 2503
Joined: Mon May 15, 2017 5:00 pm

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

Postby jlom » Mon Aug 13, 2018 5:44 am

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.
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby scottwilkerson » Mon Aug 13, 2018 1:31 pm

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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12597
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

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

Postby jlom » Mon Aug 13, 2018 2:01 pm

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
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby jlom » Mon Aug 13, 2018 2:16 pm

I'm working off of this doc.

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

just wondering what i could be missing.
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby scottwilkerson » Mon Aug 13, 2018 2:54 pm

can you show the host configuration for for the host that starts on line 1391 of hosts.cfg
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12597
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

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

Postby jlom » Mon Aug 13, 2018 3:18 pm

Code: Select all
define host {
host_name testbox1
contacts unix-pager
use systems-host
notification_interval 15
contact_groups systems-mailer
notification_period critical
}
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby jlom » Mon Aug 13, 2018 3:19 pm

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
jlom
 
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Postby scottwilkerson » Mon Aug 13, 2018 4:40 pm

You don't by chance have multiple systems-host templates in your configs do you?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
scottwilkerson
DevOps Engineer
 
Posts: 12597
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Next

Return to Nagios Core

Who is online

Users browsing this forum: No registered users and 21 guests