Lyris User's Guide
[previous] [next] [contents]
Unix Administration
Table of Contents
Introduction
Lyris Email Commands
Web Interface for Users
Server Administrator
Site Administrator
List Administrator
Other Topics
Add-On Packages
Installing and Upgrading
Appendix
Frequently Asked Questions
DocBots
Running Lyris
Email
Lyris Administration
Web Browsers
Usenet Newsgroups
International
Other FAQ issues
Mailing List Features
Perl/Lyris Toolkit
Unix Administration
Up & Coming

Unix Administration

This perl script checks to make sure that a given Lyris host is working properly, by going to the Lyris Web Interface and making sure the page displays correct information. If there appears to be a problem, an email message is sent off.

We recommend that you place this script in your Unix cron table, and have it periodically check the status of your Lyris server.

To use this program, use the following command line:

./chklyris.pl http://clio.lyris.net/cgi-bin/lyris.pl root 10

The parameters are:
* the URL to check (which needs to be the Lyris web interface)
* the email address to send notifications to
* the slowest acceptable time for the Lyris Web interface to respond. If the average is slower than this, a notification is sent.

Depending on the location of sendmail (default is /usr/lib/sendmail) and lynx (default is /usr/local/bin/lynx) on your Unix system, you may need to edit the variables at the top of this script.

#!/usr/bin/perl

# chklyris - checks the main lyris web page, mails admin if this
# fails or took longer than X number of seconds
#
# This script is useful for periodic checking of your Lyris site.
# If the Lyris web interface does not display "Main Menu" when
# this script loads up the page, then something is wrong with
# your Lyris server, and a warning message gets emailed to the
# email address you provided. Also, if the page takes too long
# to load, then something is also probably wrong, and this also
# triggers an email warning.

# for example, our unix crontab looks like this:
# 5 * * * * /web/bin/chklyris http://clio.lyris.net/cgi-bin/lyris.pl root 8 >/dev/null
# 35 * * * * /web/bin/chklyris http://clio.lyris.net/cgi-bin/lyris.pl root 8 >/dev/null
#
# These cron entries check our Lyris server twice an our, at 5 minutes past the hour,
# and at 35 minutes past the hour. If a failure occurs, or the page takes longer, on
# average, than 8 seconds to load, then a warning message is sent to root.

# command line format:
#
# chklyris http://clio.lyris.net/cgi-bin/lyris.pl root@clio.lyris.net 10
# URL-TO-CHECK ADMIN-MAIL TIME-OUT

# Copyright 1997 Shelby Group Ltd.

# location of lynx on your system
# note: your version of lynx must be capable of the "-dump" command line option
$lynx = "/usr/local/bin/lynx";

# the location of sendmail on your system
$mailprog = '/usr/lib/sendmail';

# the number of passes to make with the check
$passes = 2;

$failures_to_allow = 0;

# the phrase to look for on the lyris URL
$keyphrase = "Main Menu";

###########################################################################
# You probably do not have to edit anything below this

# the number of failures
$failures = 0;


$TimeStart = time;

$URL = $ARGV[0];
if (index($URL, "http") < 0) {
print "Please place URL in http:// format on command line\n";
print "Example: http://clio.lyris.net/cgi-bin/lyris.pl root\@clio.lyris.net 10\n";
exit
};

$EMAIL = $ARGV[1];

$OKTIME = $ARGV[2];
if ($OKTIME < 1) {
print "Please place acceptable average delay time on command line\n";
print "Example: http://clio.lyris.net/cgi-bin/lyris.pl root\@clio.lyris.net 10\n";
exit
};

@FullQuery = ($lynx,"-dump", $URL);

# do the queries, by using "lynx -dump URL"
for ($EachPass = 0; $EachPass < $passes; $EachPass++) {
open(LYNXQ, "-|") || exec (@FullQuery);

$InString = "";

while ($InLine = <LYNXQ>) {
$InString .= $InLine;
}
close(LYNXQ);
if (index($InString,"access start file") > -1) {$failures++; }
if (index($InString, $keyphrase) < 1) {$failures++; }
}

$TimeEnd = time;
$TimeDiff = $TimeEnd - $TimeStart;
print "$passes lookups of $URL took $TimeDiff seconds, an average of ";
print ($TimeDiff/$passes);
print " seconds/fetch\n";
print "There were ".$failures." failed lookups\n";

if ((($TimeDiff/$passes) > $OKTIME) || ($failures > $failures_to_allow) ){
&MailVariables;
};

sub MailVariables {

if ((open (MAIL, "|$mailprog $EMAIL")) == 1) { }
else {
print MAIL "From: Lyris Checker <jbuckman\@shelby.com>\n";
print MAIL "Subject: Lyris Checker Report\n\n";
print MAIL "$passes lookups of $URL took $TimeDiff seconds,\n";
print MAIL "an average of ".($TimeDiff/$passes)." seconds/fetch.\n";
print MAIL "\nThere were ".$failures." failed lookups\n";
close (MAIL);
}
}

Other pages which link to this page:
  • Frequently Asked Questions
  • Page 555 of 556