check_http from CLI works

My command from the command line is as follows:

./check_http -H -S -t 15 -w 5 -c 10 -f follow

Result: HTTP OK HTTP/1.1 200 OK - 5124 bytes in 0.690 seconds |time=0.689690s;5.000000;10.000000;0.000000 size=5124B;;;0

When Nagios calls it, it results in a Warning state:

Result: HTTP WARNING: HTTP/1.1 403 Forbidden

Anybody have any ideas?

Thanks ya’alls.
cluckinchicken

is the command line test done as user nagios?

whats your command definition? and the service def?

CLI test is done as root. I’ve run it under the nagios user, and returns proper result, like the root user.
The page redirects, as shown with the -f switch.

command def:
define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$
}

service def:
define service{
use generic-service
host_name
service_description Check website
is_volatile 0
check_period 24x7
max_check_attempts 10
normal_check_interval 5
retry_check_interval 5
contact_groups IT
notification_options w,u,c,r
notification_interval 0
notification_period 24x7
check_command check_http!-H -S -t 10 -w 5 -c 10 -f follow
}

by what you have the command will always be the same.

check_http -H hostaddress.

You are passing a parameter (what follows the “!”) but it will be ignored as the command doesn’t know what to do with it.

you need to change your command definition to take into account the additional parameters

create a check_http2 command (considering your parameters are always the same)

define command{
command_name check_http2
command_line $USER1$/check_http -H $HOSTADDRESS$ -S -t 10 -w 5 -c 10 -f follow
}

check_command check_http2 would then be what is needed.

keep in mind that $HOSTADDRESS$ resolves to the servers ip as defined in the host definiton.
If you use virtual hosts that would be a problem.

you may want to modify that additionaly like the following (my linux boxes are dead so i’m going from mind use check_http --help from CLI to get the right switches)

define command{
command_name check_http2
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -S -t 10 -w 5 -c 10 -f follow
}

using in the following service definition
check_http!HOSTNAME

HOSTNAME is the first parameter and it get’s substituted instead of $ARG1$.

Hope it’s clear enough… if not please check the docs for variables or parameters :wink:

Happy experimenting :slight_smile:

I did create another command definition, but I hadn’t quite gotten to the point of adding all my arguments in there, rather than my service definition. But I did get it working, and this is what I did:

command_line $USER1$/check_http -H $HOSTADDRESS$ -S -t 10 -w 5 -c 10 -f follow

check_http_www!-H

Thanks Luca! You’re the bomb! :smiley:

cluckinchicken

thanks :mrgreen: Still I think the last part is useless…

As you don’t have a $ARG1$ in your command definiton you can probably use check_http by itself without any change.

Oh and better DO create a check_http2 instead of modifying check_http keep the standard commands as they are, you never know when you need them :smiley:

Anyway looks like you got the point of the problem… :slight_smile:

Luca