Page MenuHomec4science

webstat.in
No OneTemporary

File Metadata

Created
Tue, Jun 18, 11:29

webstat.in

#!/bin/sh
## -*- mode: script; coding: utf-8; -*-
##
## $Id$
##
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## fill config variables:
VERSION='$Id$'
LISPIMAGEDIR=@prefix@/lib/lisp/invenio
CONFIGDIR=@prefix@/etc/webstat
CLISP=@CLISP@
CMUCL=@CMUCL@
SBCL=@SBCL@
## usage helper function:
usage () {
echo "Usage:" $0 "[options] <httpd-log-file>"
echo "General options:"
echo " -h, --help Print this help."
echo " -V, --version Print version information."
echo "Description: print interesting usage stats from the Apache log file."
echo "Note: Please analyze only moderately-sized logs, e.g. for a day or a week."
}
## looking for version number?
if [ "$1" = "-V" ] || [ "$1" = "--version" ]; then
echo $VERSION
exit 0
fi
## looking for help?
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
exit 0
fi
## do we have enough arguments?
if [ ! -n "$1" ]; then
echo "Error: Not enough arguments."
usage
exit 1
fi
## are input files okay?
FILECFG=${CONFIGDIR}/webstat.cfg
FILELOG=$1
if [ ! -f $FILECFG ]; then
echo "Error: config file ${FILECFG} not found."
exit 1
fi
if [ ! -f $FILELOG ]; then
echo "Error: httpd log file ${FILELOG} not found."
exit 1
fi
## check which Common Lisp implementation to use?
if [ "$LISP" == "" ]; then
LISP=cmucl
if [ ! -s ${LISPIMAGEDIR}/webstat.$LISP.core ]; then
LISP=sbcl
if [ ! -s ${LISPIMAGEDIR}/webstat.$LISP.core ]; then
LISP=clisp
if [ ! -s ${LISPIMAGEDIR}/webstat.$LISP.mem ]; then
echo "Error: no suitable Lisp images found in ${LISPIMAGEDIR}."
exit 1
fi
fi
fi
fi
## okay, try to run the process:
if [ "$LISP" == "cmucl" ]; then
$CMUCL -core ${LISPIMAGEDIR}/webstat.$LISP.core -quiet -batch \
-eval "(progn (analyze-httpd-log-file \"$FILECFG\" \"$FILELOG\")(quit))"
elif [ "$LISP" == "sbcl" ]; then
$SBCL --noinform --core ${LISPIMAGEDIR}/webstat.$LISP.core \
--eval "(progn (analyze-httpd-log-file \"$FILECFG\" \"$FILELOG\")(quit))"
elif [ "$LISP" == "clisp" ]; then
$CLISP -q -M ${LISPIMAGEDIR}/webstat.$LISP.mem \
-x "(progn (analyze-httpd-log-file \"$FILECFG\" \"$FILELOG\")(quit))"
else
echo "Error: $LISP not supported. Please read README."
exit 1
fi

Event Timeline