NagiosXI Service Template Inheritance

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mlopez
Posts: 62
Joined: Fri Oct 19, 2012 11:35 am

NagiosXI Service Template Inheritance

Post by mlopez »

Hi All,
I created the service beforehand and just created the Hostgroup, Servicegroup, Host and Service Template and applied it to an existing service and host. When changing the parameters on the "Service Template" it's not changing the associated Service. After reading more on the cause it seems to be related to the "Register" value which needs to be 0 and not 1 but I cannot figure out how to change this value as the config file under "/usr/local/nagios/etc/services" is getting changed back as per NagiosQL as per the big warning when opening the file.

--------------------
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios QL will overwite all manual settings during the next update

--------------------



Below is the service:

Code: Select all

define service {
        host_name                       20098
        service_description             upsFailureNotify
        use                                  upsFailureNotify_service
        servicegroups                   upsFailureNotify_servicegroup
        is_volatile                     1
        max_check_attempts              1
        check_interval                  1
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        notification_interval           1
        notification_period             xi_timeperiod_24x7
        notifications_enabled           1
        contacts                        nagiosadmin
        stalking_options                o,w,c,u,
        icon_image                      snmptrap.png
        _xiwizard                       snmp_trap
        [b]register                        1[/b]
        }
Any help would be greatly appreciated.

Sincerely,
Michael
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NagiosXI Service Template Inheritance

Post by tmcdonald »

Were these created in the CCM or by hand on the command line? If in the CCM, you will need to create a template under the Templates section and it will have 'register 0'. Also, know that if you have a value in a template and you set that same value in the service that uses the template, the value in the service will take precedence.
Former Nagios employee
mlopez
Posts: 62
Joined: Fri Oct 19, 2012 11:35 am

Re: NagiosXI Service Template Inheritance

Post by mlopez »

Hi TMC,
These were created using the CCM, is there any way to flip them to Register 0 through the specific service GUI? I must be blind because I can't find the option.

BTW below is my setting for the upsFail service which specifies "Register 0" at the template level.

Code: Select all

define service {
       name                                    upsFailureNotify_service
       host_name                                *
       hostgroup_name                           sms_host
       service_description                      upsFailureNotify SNMP Traps
       servicegroups                            upsFailureNotify_servicegroup
       check_command                            check_dummy!!!!!!!!
       is_volatile                              1
       initial_state                            o
       max_check_attempts                       1
       active_checks_enabled                    0
       passive_checks_enabled                   1
       flap_detection_enabled                   0
       notification_period                      24x7
       notifications_enabled                    1
       contacts                                 nagiosadmin
       contact_groups                           admins
       stalking_options                         o,w,c,u,
       icon_image                               snmptrap.png
       register                                 0

}
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NagiosXI Service Template Inheritance

Post by abrist »

mlopez wrote:is there any way to flip them to Register 0 through the specific service GUI? I must be blind because I can't find the option.
Not really. Templates and object configs are treated as metaphysically different "things" in Nagios QL - they sit in different tables and have different relations. You could copy the config file, change the desired values, and then import it back into XI, but for one config, you may find it much faster to just recreate the object in the correct Aristotelian Category.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
povachon
Posts: 44
Joined: Thu Apr 10, 2014 9:24 am
Contact:

Re: NagiosXI Service Template Inheritance

Post by povachon »

Have the same issue here. I understand we cant change de register option from 0 to 1 in gui. I make the change in CLI and save the file. As soon as i import de Template back, my change have been destroy.

So how can i change that setting plz.

Regard
PO
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: NagiosXI Service Template Inheritance

Post by sreinhardt »

You need to set register to 0 and remove service description entirely. These were the only two items from a normal service config file that I needed to modify to have it properly import as a template. Note that the name field will be how it is referenced inside CCM, so you may want to alter that too.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
mlopez
Posts: 62
Joined: Fri Oct 19, 2012 11:35 am

Re: NagiosXI Service Template Inheritance

Post by mlopez »

Hi Spenser,
Figured out the "Register 0" for services.

What I did is create "Service Templates" for each one and tied it to a hostgroup_name as shown below:

Code: Select all

define service {
       name                                     upsFailureNotify_service
       host_name                                *
       hostgroup_name                           host
       service_description                      upsFailureNotify SNMP Traps
       servicegroups                            upsFailureNotify_servicegroup
       check_command                            check_dummy!!!!!!!!
       is_volatile                              1
       initial_state                            o
       max_check_attempts                       1
       check_interval                           1
       retry_interval                           1
       active_checks_enabled                    0
       passive_checks_enabled                   1
       check_period                             xi_timeperiod_24x7
       flap_detection_enabled                   0
       notification_interval                    1
       notification_period                      xi_timeperiod_24x7
       notification_options                     w,c,u,r,
       notifications_enabled                    1
       contacts                                 nagiosadmin
       contact_groups                           admins
       icon_image                               snmptrap.png
       register                                 0

}


Now I was wondering about Host Templates, I created a Host Template when creating the host, I do the following:


I add a new host under the CCM -> HOSTS:
- Go under the Host settings and configure the following:
- (Common Settings) Put in the name, IP, Description
- (Common Settings) Manage Templates (Tie it to a Template)
- (Common Settings) Manage Hostgroups (Tie it to a Hostgroup)
- (Alert Settings) Manage Contacts (Tie it to contacts)
- (Alert Settings) Manage Contactgroups (Tie it to Contactgroups)


below is an example of one of my hosts:

Code: Select all

define host {
        host_name                       TMR54
        use                             snmptrap_host
        alias                           ROMERO
        address                         192.168.1.18
        hostgroups                      host
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        contacts                        nagiosadmin
        contact_groups                  admins
        notification_interval           60
        notification_period             xi_timeperiod_24x7
        notification_options            d,r,
        notifications_enabled           1
        register                        1
        }
Am I doing this all wrong? Any advise would be greatly appreciated as all my Hosts have the same config and want to be able to change them all in 1 shot instead of going one by one when I need to do a modification, as this is a larger set up it would be ideal for mass changes.

Sincerely,
Michael
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NagiosXI Service Template Inheritance

Post by abrist »

mlopez wrote:Am I doing this all wrong? Any advise would be greatly appreciated as all my Hosts have the same config and want to be able to change them all in 1 shot instead of going one by one when I need to do a modification, as this is a larger set up it would be ideal for mass changes.
No, you mostly got it. I would suggest setting contactgroups on the templates and contacts in contactgroups only, so that adjusting contactgroups is only done through a template, and adjusting contacts is done purely through the contactgroups.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mlopez
Posts: 62
Joined: Fri Oct 19, 2012 11:35 am

Re: NagiosXI Service Template Inheritance

Post by mlopez »

Hi abris,
You may close this thread as your explanation has resolved my issue.

Sincerely,
Michael
Locked