Error: Could not find a service matching host name

Hello all

Hopefully one of you Nagios experts can give me a hand with this!

I have deployed Nagios a few times now and in an older Nagios 2.x deployment I had Dependencies working perfectly but I had defined every service individually for every host.
In my latest deployment of Nagios I have taken advantage of the new features in using Templates to control Services for multiple hosts etc but it seems I have run into trouble when it comes to defining dependencies for the services.

I’ll try to describe whats happening, during the pre-flight check I get the following error:
Error: Could not find a service matching host name ‘testlab’ and description ‘service1’ (config file ‘/dependencies.cfg’, starting on line 4)
Error: Could not expand dependent services specified in service dependency (config file ‘/dependencies.cfg’, starting on line 4)
Error processing object config files!

define servicedependency{
host_name testlab
service_description PING
dependent_host_name testlab
dependent_service_description service1
notification_failure_criteria c,u
execution_failure_criteria n
}

So it will check the host for the ‘service1’ service. The problem with this is that it is defined as follows:
define service{
use service1
host_name testlab
}

Which is using this as a template:
define service{
name service1 ; The ‘name’ of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness’
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups admins ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

I thought this may have just been a bug in the version of Nagios I was running but it seems to still happen in the 3.1.0 version. Kinda hoped it would just go away with an upgrade but no luck =)
Found the following article osdir.com/ml/network.nagios.deve … 00002.html

However they identify the problem as “problem with parsing service dependency templates
that specify “hostgroups” without “dependent_hostgroups” or vice versa.” which i’m not sure is what I’m seeing. They also have a ‘Register 0’ in the servicedependency definition which just causes mine to ignore the servicedependency altogether - which tbh is what I’d expect.

So yes, has anyone ran into this problem when using Service Templates and Dependencies? Any advice or ideas would be appreciated.

Cheers

It can’t find the service 1 you’re defining because you have named the template as service 1. You should define template with the name, for example, service1_template, and then define the service like this:

define service{
use service1_template
host_name testlab
service_description service1
}

The error comes because you have defined the service without service_description which Nagios uses as the service name, and because you have defined the template with the name you would like to use for service name (service_description.

Hello Albin, thank you, I appreciate the reply.

I have followed your instructions:

  • Changed the Template service name
  • Included the service_description in the service definition

I have also made sure to use the service description defined in the service when listing the ‘dependent_service_description’ in the dependency definition.

Unfortunately I am still having problems as I have now got a new error

"Processing object config file '/usr/local/nagios/etc/objects/dependencies.cfg'... Error: Service description, host name, or check command is NULL Error: Could not register service (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 56) Error processing object config files!"

I thought it was maybe because the template does not have a service description so I have also tried it the other way around with it definied in the Service Template rather than the actual Service definition for the host. But this did not make any difference - same error as above.

I’ll keep workin on this but any other ideas would be appreciated.

Cheers

Hi Lonestar,

I’m afraid that Service Dependencies won’t work as expected. Take a look at:

viewtopic.php?f=59&t=5104&p=16828&hilit=dependencies#p16828

Hope it helps.