Inheritance doesn't seem to be working for config templates

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
jlom
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

Inheritance doesn't seem to be working for config templates

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jlom
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post 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
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
jlom
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

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

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

Post by jlom »

I'm working off of this doc.

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

just wondering what i could be missing.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

can you show the host configuration for for the host that starts on line 1391 of hosts.cfg
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
jlom
Posts: 17
Joined: Mon Dec 04, 2017 4:49 pm

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

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

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

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

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

Post by scottwilkerson »

You don't by chance have multiple systems-host templates in your configs do you?
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked