Template could not be found

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.
Locked
User avatar
Pitone_Maledetto
Posts: 69
Joined: Fri Jul 01, 2016 4:11 am
Location: Liverpool, United Kingdom

Template could not be found

Post by Pitone_Maledetto »

Hi all,
I have set-up Nagios with some templates which all work fine.
Yesterday I needed a new .cfg file in order to add more template but every-time I try to check the configuration I get the following error.
Error: Template 'LOP-COU' specified in service definition could not be not found

To double check that the .cfg was being read by Nagios I copied and pasted the same service definition inside the host definition and I got
a duplicate definition error; so I know that the file is being read.

I have setup this new service template not different form many that I have setup before so I am not sure why Nagios is starting to misbehave.

This is how the service is setup inside the new .cfg file:

Code: Select all

define service {
        use                     generic-service
        name                    LOP-COU             # LOP = Processor, COU = Count
        host_name               myserver
        servicegroups           Processor
        service_description     Proc_COU
        check_command           check_procscount_ssh!Processor!1:1
        max_check_attempts      1
        register                0
    }
This is how I call the template:

Code: Select all

define service {
        use                     LOP-COU
        host_name               myserver
        }
Any help would be greatly appreciated.
Regards
Last edited by Pitone_Maledetto on Mon Jun 05, 2017 8:34 am, edited 2 times in total.
"It is impossible to work in information technology without also engaging in social engineering"
Jaron Lanier
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Template could not be found

Post by mcapra »

If LOP_COU is intended to exist as a template, you may need to leverage the register directive. More on that directive here:
https://assets.nagios.com/downloads/nag ... tance.html
The third variable is register. This variable is used to indicate whether or not the object definition should be "registered" with Nagios. By default, all object definitions are registered. If you are using a partial object definition as a template, you would want to prevent it from being registered (an example of this is provided later). Values are as follows: 0 = do NOT register object definition, 1 = register object definition (this is the default). This variable is NOT inherited; every (partial) object definition used as a template must explicitly set the register directive to be 0. This prevents the need to override an inherited register directive with a value of 1 for every object that should be registered.
If you were to compare your LOP_COU template to the generic-service template, I think you may notice that generic-service has register 0 set.
Former Nagios employee
https://www.mcapra.com/
User avatar
Pitone_Maledetto
Posts: 69
Joined: Fri Jul 01, 2016 4:11 am
Location: Liverpool, United Kingdom

Re: Template could not be found

Post by Pitone_Maledetto »

Hi thank you for your reply.
I did not copy and paste the correct definition.
The register 0 is set but still no joy.
I will edit the post.
Regards
"It is impossible to work in information technology without also engaging in social engineering"
Jaron Lanier
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Template could not be found

Post by avandemore »

This is your problem: # LOP = Processor, COU = Count

You can reference this page for proper syntax:

https://assets.nagios.com/downloads/nag ... tions.html
Previous Nagios employee
User avatar
Pitone_Maledetto
Posts: 69
Joined: Fri Jul 01, 2016 4:11 am
Location: Liverpool, United Kingdom

Re: Template could not be found

Post by Pitone_Maledetto »

Hi avandemore,
indeed it was.
I am so used to with bash that everything after the # is a comment that I could not see the problem.
I have ammended the definition as follow:

Code: Select all

define service {
        use                     generic-service
        name                    LOP-COU             ; LOP = Processor, COU = Count
        host_name               myserver
        servicegroups           Processor
        service_description     Proc_COU
        check_command           check_procscount_ssh!Processor!1:1
        max_check_attempts      1
        register                0
    }
now there are no errors during the pre-flight check.
Thank you all for your input and help.
Have a good day.
This can be closed as resolved.
Best Regards
"It is impossible to work in information technology without also engaging in social engineering"
Jaron Lanier
avandemore
Posts: 1597
Joined: Tue Sep 27, 2016 4:57 pm

Re: Template could not be found

Post by avandemore »

Thanks for using the Nagios forums. Please open a new thread for any further issues.
Previous Nagios employee
Locked