Strange problem about Host definition (check_command)

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
Ismo

Strange problem about Host definition (check_command)

Post by Ismo »

Dear all,

I have a strange problem.
When I define a host (like below), all works fine. In nagios, I have this message for this host:
HTTP OK: HTTP/1.1 301 Moved Permanently - 539 bytes in 0.003 second response time

Definition of the host:

Code: Select all

define host{
	use	generic-geo-host
	host_name	<Name_of_the_host>
	parents	localinternetgateway
	address	             <IP address of the host>
	contacts	nagios-admin
	action_url	<address of the host ;eg http//host> 
}
Template used :

Code: Select all

define host{
        name                            generic-geo-host    ; 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
	notification_period		24x7		        ; Send host notifications at any time
        check_period                    24x7                    ; By default,  hosts are checked round the clock
        max_check_attempts              5                      ; Modify to 5 !!Check each host 10 times (max)
        check_command                   check_http              ; Default command to check hosts
        notification_interval           1440                    ; Resend notification every 24 hours
        notification_options            d,u,r                   ; Only send notifications for specific host states
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
However, if I define the same host like this (add a check_command):

Code: Select all

define host{
	use	generic-geo-host
	host_name	<Name_of_the_host>
	parents	localinternetgateway
	address	             <IP address of the host>
	contacts	nagios-admin
check_command   check_http-custom!'<address of the host>'
	action_url	<address of the host ;eg http//host> 
}

with

Code: Select all

define command {
        command_name check_http_custom
        command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$
}
I have this message:
HTTP WARNING: HTTP/1.1 400 Bad Request - 464 bytes in 0.004 second response time |time=0.003714s;;;0.000000 size=464B;;;0

If I type this command directly, I have the same error message:

Code: Select all

 ./check_http -H <address of the host> -u  ‘<address of the host >’ 
(Even if –u is useless for hosts check)

This difference generates temporally critical timeout (CRITICAL - Socket timeout after 10 seconds) for the concerned host and also for some services associate at this host.
These timeout errors are not present with the first configuration.

I would like to know:
What is the exact command that execute during the first (without define check_command) configuration?
What are the differences between the two configurations about the check_http?

Another question: I know that our host server doesn’t accept HEAD request. May it cause errors?
Thanks in advance for your answers

Corentin
Last edited by Ismo on Thu Jan 09, 2014 4:03 am, edited 1 time in total.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Strange problem about Host definition (check_command)

Post by tmcdonald »

What is the exact command that execute during the first (without define check_command) configuration?

According to the generic-geo-host template, check_http is being used. The exact command should be check_http -H $HOSTADDRESS$

What are the differences between the two configurations about the check_http?

The first one uses the command above, while the second uses check_http -H $HOSTADDRESS$ -u 'http://tds0.ifremer.fr'

Unfortunately in this case I do not know why there would be an error like that. It could be that the host IP has several sites running, addressed by URL. When you omit the URL it goes to the base server, whereas including the -u option specifies a site to check. This is just a guess.

I know that our host server doesn’t accept HEAD request. May it cause errors?

I believe check_http by default makes a simple GET request, so this should not be an issue in most cases. There are options to set the method, however.
Former Nagios employee
Ismo

Re: Strange problem about Host definition (check_command)

Post by Ismo »

Hi, thanks for your reply.

Indeed, if I replace

Code: Select all

check_command   check_http-custom!'<address of the host>' 
by

Code: Select all

check_command   check_http
in the host definition, it's works (this is the same as using the template).

I will use this method to fix my problem.

Thanks again

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

Re: Strange problem about Host definition (check_command)

Post by tmcdonald »

Awesome. Let us know if this works for you, otherwise I'll be closing this thread here in a bit.
Former Nagios employee
Locked