check_http difficulty


#1

Hello. I would like to use check_http to check a webpage for a certain word to see if it’s working correctly. If I run check_http from the command line, it works fine:

check_http -H uranus.wsg.com -u “http://uranus/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/main.xts&startwel=yes” -f follow --string=Query
HTTP OK: HTTP/1.1 200 OK - 2161 bytes in 0.122 second response time |time=0.121526s;;;0.000000 size=2161B;;;0

I know that it’s checking the page correctly because if I query for a word that isn’t on that page I get an error:

[root@nagios public_servers]# check_http -H uranus.wsg.com -u “http://uranus/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/main.xts&startwel=yes” -f follow --string=blah
HTTP CRITICAL: HTTP/1.1 200 OK - string not found - 2161 bytes in 0.188 second response time |time=0.187861s;;;0.000000 size=2161B;;;0

I have my configuration file for this website configured like this:

define service{
use generic-service ; Inherit default values from a template
host_name uranus
service_description Check page content for the word password
check_command check_http! -H uranus.wsg.com -u “http://uranus/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/main.xts&startwel=yes” -f follow --string=Query
}

I force a check in Nagios and see this in the Nagios logs:

[1259099722] EXTERNAL COMMAND: SCHEDULE_FORCED_HOST_SVC_CHECKS;uranus;1259099722
[1259099723] SERVICE ALERT: uranus;Check page content for the word password;CRITICAL;SOFT;1;HTTP CRITICAL: HTTP/1.1 404 Not Found - string not found - 478 bytes in 0.004 second response time

What can I do to fix this? What did I do wrong?


#2

Not sure if this is the cause of your problem, but it makes for a cleaner config and easier customisation:

check_command check_http! -H uranus.wsg.com

why is the ! in there?
that command is badly defined.
the command cfg should be something like:

command name my_check_http
check_http -H $ARG1$ -u $ARG2$ -f $arg3$ --string=$arg4$

and the service def should look like:

my_check_http!uranus.wsg.com!“http://uranus/cognos8/cgi-bin/cognos.cgi?b_action=xts.run&m=portal/main.xts&startwel=yes”!follow!QUery

Check the docs about how to define commands and services :wink: