Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80250305
webstat.in
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Aug 30, 17:09
Size
3 KB
Mime Type
text/x-shellscript
Expires
Sun, Sep 1, 17:09 (2 d)
Engine
blob
Format
Raw Data
Handle
20330741
Attached To
R3600 invenio-infoscience
webstat.in
View Options
#!/bin/sh
## -*- mode: script; coding: utf-8; -*-
##
## $Id$
##
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 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?
FILEORIG=${CONFIGDIR}/webstat.cfg
FILECFG=`tempfile`
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
## create config file for Lisp
echo ";;; -*- Mode: LISP; Syntax: COMMON-LISP; -*-" > $FILECFG
echo ";;;" >> $FILECFG
echo ";;; webstat config file" >> $FILECFG
echo "" >> $FILECFG
apache_section=""
exec 3<&0
exec 0<$FILEORIG
while read line
do
if [ "`echo $line |grep '\[.*\]'`" ]
then
apache_section=""
fi
if [ $apache_section ]
then
if [ "`echo $line|grep '='`" ]
then
echo $line |sed 's/^/(defvar */'|sed 's/$/)/'|sed 's/ = /* /' >> $FILECFG
fi
fi
if [ "`echo $line |grep '\[apache_log_analyzer\]'`" ]
then
apache_section="True"
fi
done
exec 0<&3
echo "" >> $FILECFG
echo ";;; end of file" >> $FILECFG
## 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
rm $FILECFG
Event Timeline
Log In to Comment