Page 1 of 1
Templates not working..
Posted: Wed Nov 06, 2019 4:32 am
by ShlomiUni
Hi, I'm trying to configure templates for my nagios xi system.
I tried 'Service Template' & 'Contact Template'
So for the service template I edited 'generic-service' template and added all the check settings and alerts settings for what I need.
Then I save and apply, and goes to a service and then from 'Manage Templates' I select the template I made and save & apply.
I thought it should update my service with the service template settings but it just doesn't change anything.. it doesn't import any settings from the template to the service.
Same for the 'Contact Templates' I edited 'generic-contact' template and edited with my own settings, Then I create a new contact and selects the 'generic-contact' template, Also no settings are applied to the new contact.
Am I missing something? I'm doing it wrong?
I'm just trying to create a template for check settings & alert settings for services / hosts / contacts so I don't need to manually change it for every new object.
Thanks
Re: Templates not working..
Posted: Wed Nov 06, 2019 9:28 am
by lmiltchev
Do you have the same variables (as the ones you have in the template) defined locally, on the service level? Local variables will take precedent over inherited variables from a template. Read more on object inheritance here:
https://assets.nagios.com/downloads/nag ... tance.html
Also, to be sure what are your actual settings of an object, you will need to view the service config in the /usr/local/nagios/var/objects.cache file.
If you have any further (specific) questions, please post the configs for the service, and the template this service is currently using. Explain what variables in your opinion should be inherited, but they are not. Thanks!
Re: Templates not working..
Posted: Wed Nov 06, 2019 11:00 am
by ShlomiUni
lmiltchev wrote:Do you have the same variables (as the ones you have in the template) defined locally, on the service level? Local variables will take precedent over inherited variables from a template. Read more on object inheritance here:
https://assets.nagios.com/downloads/nag ... tance.html
Also, to be sure what are your actual settings of an object, you will need to view the service config in the /usr/local/nagios/var/objects.cache file.
If you have any further (specific) questions, please post the configs for the service, and the template this service is currently using. Explain what variables in your opinion should be inherited, but they are not. Thanks!
Hi, Thank you for the reply.
I just finished reading the article you provided and I followed the instructions, I still can't get it working.. I will try to explain what I'm doing:
So I'm using a fresh install of Nagios XI and I'm only monitoring "Nagios" host.
I edited the service template "local-service" like this:
Code: Select all
define service {
name local-service
use generic-service
max_check_attempts 3
check_interval 3
retry_interval 1
check_period xi_timeperiod_24x7
notification_interval 60
notification_period xi_timeperiod_24x7
notification_options w,c,r,f,
notifications_enabled 1
contact_groups Tech
register 0
}
Then, I created a new service for the host "Nagios" as Nagios-Test-Service, as the following:
Code: Select all
define service {
host_name Nagios
service_description Nagios-Test-Service
use local-service
check_command check-host-alive!!!!!!!!
register 1
}
and I applied settings.
I suppose I should see the template settings in my new created service, no?
Am I missing something again? :X
Re: Templates not working..
Posted: Wed Nov 06, 2019 11:02 am
by ShlomiUni
"local-service" template is located in "/usr/local/nagios/etc/servicetemplates.cfg"
and "Nagios-Test-Service" is located in "/usr/local/nagios/etc/services/Nagios.cfg"
Re: Templates not working..
Posted: Wed Nov 06, 2019 11:32 am
by lmiltchev
I suppose I should see the template settings in my new created service, no?
No, if you don't have max_check_attempts, check_interval, retry_interval, check_period, etc. defined locally (in the service config),
you are not going to be able to see them in the actual config. You would see this line:
which tells you that you are inheriting these variables from the "local-service" template. You could view the template's config to see what these values are. Also, you could view the "current" config of the service in the
objects.cache, just to make sure it contains the desired directives. Have you reviewed the service definition of "Nagios-Test-Service" in objects.cache?
You haven't modified the configs from the command line, have you? You must do all of the changes under the Core Config Manager (CCM), then apply configuration. If you modified configs manually (from the CLI), as soon as you apply configuration, all of the changes that you made would be overwritten with whatever is in the database (CCM). FYI.