check_http with pattern matching

Matt Pounsett matt.pounsett at cira.ca
Wed Feb 11 20:26:28 CET 2004


On Wed, 11 Feb 2004, Andreoni Antonella wrote:

> I need to check the content of a web page
> the web page is the result of a jsp and it may contain the "OK" string or
> the "ERROR" string depends on the jsp can connect to a DB or not
> if it contains "OK" then Nagios status for the service must be "Normal" 
> if it contains "ERROR" then Nagios status for the service must be "Critical" 

It looks like the problems you're having are related to a misunderstanding of
the way arguments work in Nagios service definitions.

In your first example, your service definition uses this check command:

>  check_command check_http!my.host.domain!/Sil/test-monitor.jsp!200!"Database: Status: OK"

And this is the example you give for the accompanying command definition:

>  command_line    $USER1$/check_http -H $HOSTADDRESS$

Now... each ! you have in your check_command line creates a new argument
($ARGn$) which is passed to the check command's command_line.   In this case,
you're throwing away all of your arguments, and only referring to
$HOSTADDRESS$, which is set by the 'address' parameter to your host
definition.  So basically, all this does is check to see that your httpd
answers port 80 appropriately... you're not actually checking any content.

Your second example is closer, but still misses the mark a bit.  For
reference, here's the altered command_line from your new command definition:

>  command_line    $USER1$/check_http -H $HOSTADDRESS$ -u $ARG1$ -e $ARG2$ -s $ARG3$

Again, you're throwing away arguments.. though, fewer this time.  However,
your real problem comes from the fact that you're using arguments in incorrect
places.  Here's a breakdown of the variables set by the check_command line
above:

$ARG1$ = my.host.domain
$ARG2$ = /Sil/test-monitor.jsp
$ARG3$ = 200
$ARG4$ = "Database: Status: OK"

Now.. I don't know what IP address you have assigned to this host, so I'll
just use 'xx.xx.xx.xx' as a place holder for it.  Using that assumption,
here's what actually gets run by your command_line:

check_http -H xx.xx.xx.xx -u my.host.domain -e /Sil/test-monitor.jps -s 200

Do you see where the problem is now?
Hope this helps...
   Matt

-- 
Matt Pounsett                 CIRA - Canadian Internet Registration Authority
Technical Support Programmer                    350 Sparks Street, Suite 1110
matt.pounsett at cira.ca                                 Ottawa, Ontario, Canada
613.237.5335 ext. 231                                      http://www.cira.ca



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list