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

NAME

check -- URL checker for MiniVend

SYNOPSIS

 $prog [-doz] [-a page] [-e error\@address] [-g n] [-p /path/to/script] \\
       [-r restart_script] [-s SCRIPT_NAME] [-t period] [-m mailprog]

DESCRIPTION

This URL checker will test the health of MiniVend and restart it if appropriate. In its simplest form, you can just run it and it will stay in the background, executing the link program every 60 seconds to see if it gets a page back from MiniVend. It relies on the default page (normally catalog.html) being of greater than a certain watermark (default is 500 bytes).

It could be extended to check most any program, and can check the actual web server itself with the LWP libraries and a Perl script like:

        use LWP::Simple;
        getprint "http://localhost/cgi-bin/simple";

If MiniVend is not responding, its link program will time out and respond with a short error message that should be less than the watermark. At that time, the restart script will be run once. If the restart fails, then the RESTART_HARD setting will be run. If you define a custom restart script passed with the -r option, then a -f will be appended to it as a parameter to indicate a hard restart.

Counts of good and bad runs are kept in the MiniVend root directory in the files .bad.count and .ok.count -- PID is in .check.pid, and is locked to prevent two programs running at the same time.

OPTIONS

  -a  Alternate page to check
  -d  Display parameters
  -e  Error address
  -g  Size of output considered good (default 500)
  -m  Mail program
  -o  Run once
  -p  Script path to use
  -r  Script to run on restart
  -s  Script alias to use
  -t  Check period in seconds (approximate), default 60
  -z  zero counts

EXAMPLES

For constant checking, you can just run it from the command line:

        check &

To zero the counts:

        check -z &

You can zero the counts while it is running by sending the process a hangup signal:

        kill -HUP `cat /home/minivend/.check.pid`

To run once in a crontab to check periodically:

 11,41 * * * * /path/to/minivend/bin/check -o

To change the script to run:

        check -r /home/me/my_restart_script

To check every 10 minutes instead of every minute:

        check -t 600

If you have a very small default (catalog.html) page:

        check -g 300

(The vlink and tlink default error message returns about 250 bytes).

If your catalog.html page is less than 250 bytes (or whatever you have hacked the error message to) then you can specify a different page in the MiniVend PageDir:

        check -a prettybig.html

BUGS

Can't check for health of web server. A good indication just indicates that the link program can communicate through the TCP or UNIX-domain socket.

Must be run as the same user ID which runs MiniVend unless a custom restart script is provided.

Link timeout must be waited for. To correct this, you can compile a custom link with LINK_TIMEOUT set to a small value.

AUTHOR

Mike Heins, <mikeh@minivend.com>.