Page 1 of 1

local-service' specified in service definition

Posted: Fri Jun 08, 2012 1:28 pm
by ScottB
Hello all,
I recently added RRDTool, PNP4Nagios, PHP 5.2 and PHP Modules and now when trying to:

Code: Select all

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
I get the error:

Code: Select all

Error: Template 'local-service' specified in service definition could not be not found (config file '/usr/local/nagios/etc/objects/localhost.cfg', starting on line 150)
which is:

Code: Select all

define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }
I didn't have any problems with this until I made the modifications listed above and I'm not sure what syntax I may have goofed on. I'm sure that when I resolve this I will be able to utilize the solution to fix other problems I likely created while installing and modifying the rest of the feature.

This is a brand new installation monitoring linux and windows machines (which it seems to still be doing) on CentOS release 5.8 (Final)

I'm sorry, I searched online and didn't even bought the Self Paced training but after watching the video's I'm still not sure where I may have messed this one up. Any pointers would be greatly appreciated!

Re: local-service' specified in service definition

Posted: Fri Jun 08, 2012 1:40 pm
by agriffin
I'm not sure what caused this problem to appear after installing those components, but the problem is that are trying to use a template that doesn't exist. Look through your config files for a service named local-service (several of them may use local-service just like in the snippet you posted, try not to mix that up).

If you find a service named local-service, it may be that it's not set to act as a template or it may not be getting read at all by Nagios. If you don't find it we'll need to add it.

Re: local-service' specified in service definition

Posted: Fri Jun 08, 2012 1:58 pm
by ScottB
Thank you, I did add this to templates.cfg but so far I don't see a service named local-service. I'm still hunting.

Code: Select all

# Local service definition template - This is NOT a real service, just a template!

# define service{
#       name                            local-service           ; The name of this service template
#	use                             generic-service         ; Inherit default values from the generic-service $
#       max_check_attempts              4                       ; Re-check the service up to 4 times in order to d$
#        normal_check_interval           5                      ; Check the service every 5 minutes under normal c$
#        retry_check_interval            1                      ; Re-check the service every minute until a hard s$
#        register                        0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL S$
#       }

define host     {
        name    host-pnp
        action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
        register        0
        }

define service  {
        name    srv-pnp
        action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
        register        0
        }

Re: local-service' specified in service definition

Posted: Mon Jun 11, 2012 9:21 am
by ScottB
I think I'll need to add it... I'll try to find where to do that this AM.

Here is what I see:

Code: Select all

# pwd
/usr/local/nagios/etc

grep -r "local-service" ./
./objects/templates.cfg:#	name				local-service 		; The name of this service template
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use
./objects/localhost.cfg:        use                             local-service         ; Name of service template to use

Re: local-service' specified in service definition

Posted: Mon Jun 11, 2012 11:12 am
by ScottB
I just replaced all instances of local-service with generic-service in localhost.cfg.
Restarted Nagios and apache and this took care of the problem. Thank you for your help.

Re: local-service' specified in service definition

Posted: Mon Jun 11, 2012 12:12 pm
by agriffin
You're welcome. I'm glad you got thing worked out.