The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::HealthCheck - Checks a set of urls for conditions and puts up whatever page you want

SYNOPSIS

 <Location /health-check/>
    SetHander perl-script
    PerlModule Apache::HealthCheck
    PerlHandler Apache::HealthCheck
    PerlAddVar CheckURL "http://appserver1.example.com/ 404"
    PerlAddVar CheckURL "http://appserver1.example.com:8085/ 302"
    PerlAddVar CheckURL "http://component1.example.com:4424/ 403"
    PerlSetVar ReturnCodeSuccess 403
    PerlSetVar ReturnCodeFail 500
 </Location>

DESCRIPTION

Checks a list of urls for specific return codes and then returns a code / header / page of it's own. This is useful for web server clusters where you might have a switch or a web server performing periodic health checks on an application. This module allows you to harness the checks of all the urls (web services) a specific node might have in one easy to "check" URL.

If any of the URLs specified in the CheckURL directives fails to return the specified return code, the attempt is treated as failed, otherwise its treated as a success.

CONFIGURATION

Configuration must take place in the Apache config file using the PerlAddVar (or PerlSetVar) directives.

  • CheckURL - used to configure different URLs for checking. The syntax is "http://yoursite.example.com <return code>" where <return code> is the numeric http code you expect back from the service. NOTE: it's important that your URLs be URL encoded they must NOT contain spaces... URL encode your URLs here. Any of these URLs failing to return the specified code results in an overall failure.

  • ReturnCodeSuccess - the return code to return if all is clear (numeric valid http code 200, 302, 404, etc) (Default: 200)

  • ReturnCodeFail - the return code to return if something failed (numeric valid http code 200, 302, 404, etc) (Default: 500)

  • HeaderNameSuccess - the name of a header to return if the check is a success (Optional)

  • HeaderValueSuccess - the corresponding value for the header returned if the check is a success (Optional)

  • HeaderNameFail - the name of a header to return if the check fails (Optional)

  • HeaderValueFail - the corresponding value for the header returned if the check fails (Optional)

  • HTMLSuccess - a path to an HTML file to send if the check is a success (Optional, default prints "SUCCESS")

  • HTMLFail - a path to an HTML file to send if the check fails (Optional, default prints "FAIL")

  • TrackResultsInHeader - Keep track of each individual check in the header using X-HealthCheck-#-Success or X-HealthCheck-#-Fail should be Set to On or Off (Default: Off)

  • CheckTimeout - The amount of time (in seconds) waited before the request is aborted (Default: 10)

  • CheckUserAgent - The user agent string to send while checking the different CheckURLs. Useful for cranky web apps that return certain content for certain browsers, as well as cleaning up logs for satistical analysis (by exempting this user agent from the recorded hits).

  • CheckMethod - The HTTP method to use on the CheckURL(s). GET, POST, HEAD, etc.

SEE ALSO

The Apache Documentation (http://httpd.apache.org/docs/1.3/), the mod_perl documentation (http://perl.apache.org/docs/1.0/)

AUTHOR

Michael Gregorowicz <mike@mg2.org>

COPYRIGHT AND LICENSE

Copyright (C) 2006 by Michael Gregorowicz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available.