Problems with check_http command line vs. Nagios

I’m currently using the following in Nagios and getting a Page not Found error, but when using from the command line it’s working just fine.

check_http -H “192.168.1.5” -u “/suretyonlinetest/onlinetest.asp” -r “success”

is what I’m running in the command line, my service definition looks like this:

define service{
use generic-service
host_name Exchange
service_description WebMap Check
check_command check_http!-H “192.168.1.5” -u"/suretyonlinetest/onlinetest.asp" -r “success”
}

I have a similar test that I’m running where I’m defining the host in the check_command, so I’m pretty sure it’s not that…

any help would be appreciated.

In Nagios, you don’t define the command to run in the service or host definition. You define it in the command definition. It makes it more flexible in case you need to update the plugin one day… just one place to change it. So that command that works in the shell is what would be called in the command definition, not the service definition. The command definition lets you pass arguments to the plugin via macros.
If you check your command definitions I’m betting you see something like:

define command{
command_name check_http
command_line $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -r $ARG2$
}

if so, the -H option is already handled. It is pulled automatically from the host definition the service is associated with. So for each service, all you need to do is tell it the -u and -r options, which are $ARG1$ and $ARG2$. To do this, just call the command and separate the args with !'s:

check_command check_http!/suretyonlinetest/onlinetest.asp!success

you would also make sure that the host definition for Exchange had that IP as the ‘address’.

if you want to pass the full command line options, including the -H option in the service definition, just set up the command definition to have a single argument (which would be all of the flags and args)

define command{
command_name check_http
command_line $USER!$/check_http $ARG1$
}

Then in the service, the command_line would be:

command_line check_http!-H ipaddress -u address -r success

this is obviously not as flexible, as changes to the host’s address aren’t automatically passed down to the services.