Page 1 of 1

Could not find any host matching ... Could not expand hostgr

Posted: Wed May 25, 2011 11:59 am
by jeraisel
Hi

I'm doing the preflight check after trying to add a new service to monitor with Nagios (which I can't seem to get going) and I stumbled on the fallowing error:
Processing object config file '/usr/local/nagios/etc/objects/service.cfg'...
Error: Could not find any host matching 'RHEL_Destruir' (config file '/usr/local/nagios/etc/objects/service.cfg', starting on line 20)
Error: Could not expand hostgroups and/or hosts specified in service (config file '/usr/local/nagios/etc/objects/service.cfg', starting on line 20)
Error processing object config files!
I find it strange once I define RHEL_Destruir in another file which is processed before, called hosts1.cfg
here is service.cfg:

Code: Select all

# Service definition


define service{
        name                            servico-generico 	; 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
        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
        register                        0       		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

define service{
	use			servico-generico
	host_name 		RHEL_Destruir
	service_description 	someremoteservice
	is_volatile 		0
	check_period 		24x7
	max_check_attempts 	3
	normal_check_interval 	3
	retry_check_interval 	1
	contact_groups 		Administrador
	notification_interval 	120
	notification_period 	24x7
	notification_options 	w,u,c,r
	check_command 		check_users
}
hosts1.cfg:

Code: Select all

define host{
        name                            host-generico    ; The name of this host template
        notifications_enabled           1       	; Host notifications are enabled
        event_handler_enabled           1       	; Host 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
        register                        0       	; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }



define host{
	use				host-generico
	name				RHEL_Destruir	; IP
	address				128.1.5.20				
	check_period			24x7		; By default, Linux hosts are checked round the clock
	check_interval			5		; Actively check the host every 5 minutes
	retry_interval			1		; Schedule host check retries at 1 minute intervals
	max_check_attempts		10		; Check each Linux host 10 times (max)
        check_command           	check-users 	; Default command to check Linux hosts
	notification_period		workhours	; Linux admins hate to be woken up, so we only notify during the day
							; Note that the notification_period variable is being overridden from
							; the value that is inherited from the generic-host template!
	notification_interval		120		; Resend notifications every 2 hours
	notification_options		d,u,r		; Only send notifications for specific host states
	contact_groups			admins		; Notifications get sent to the admins by default
	register			0		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
	}

define host{
	name				128.1.0.19	; IP
	check_period			24x7		; By default, Linux hosts are checked round the clock
	check_interval			5		; Actively check the host every 5 minutes
	retry_interval			1		; Schedule host check retries at 1 minute intervals
	max_check_attempts		10		; Check each Linux host 10 times (max)
        check_command           	check-host-alive ; Default command to check Linux hosts
	notification_period		workhours	; Linux admins hate to be woken up, so we only notify during the day
							; Note that the notification_period variable is being overridden from
							; the value that is inherited from the generic-host template!
	notification_interval		120		; Resend notifications every 2 hours
	notification_options		d,u,r		; Only send notifications for specific host states
	contact_groups			admins		; Notifications get sent to the admins by default
	register			0		; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
	}
The part of nagios.cfg where I declare the both:

Code: Select all

(...)
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts1.cfg
cfg_file=/usr/local/nagios/etc/objects/service.cfg
(...)
I'm sure I'm making something wrong, but I can't figure out what.

If anyone can land me a hand I would appreciate.

Thank you

Re: Could not find any host matching ... Could not expand ho

Posted: Thu May 26, 2011 7:07 am
by jteugels
I hope it is more than the thing that my eye drops onto.
I see "hostsL.cfg" in the nagios.cfg.
While the reference in you message has "hosts1.cfg".

Jan

Re: Could not find any host matching ... Could not expand ho

Posted: Thu May 26, 2011 12:02 pm
by jeraisel
Sorry, but it's just different types of fonts.

I've figured out what was wrong. in the host definition it is supposed to be hosts_name and not name. it's a copy/paste from the Internet. that was why the pre-flight check wouldn't recognize the name of the host.

thank anyway.

Re: Could not find any host matching ... Could not expand ho

Posted: Thu May 26, 2011 12:40 pm
by tonyyarusso
Plus, you had "register 0" on the host you were trying to use.