#!/bin/ksh # # Run http-analyze for all servers # USAGE="$(basename $0) [-mdv] [MM [YYYY]]" HA_PATHNAME=/usr/local/bin/http-analyze # pathname of http-analyze HA_CONFNAME=httpd/analyze.conf # name of configuration file SERVERLIST="clientA clientB" # list of servers to analyze SERVERROOT=/www # name of the server root ECHO=": " while [ $# -gt 0 ]; do case $1 in -[md]) DEFMODE="$DEFMODE $1" ;; -v) DEFMODE="$DEFMODE $1" ; ECHO=echo ;; [01][0-9]) MONTH="$1" ;; [012][0-9][0-9][0-9]) YEAR="$1" ;; *) echo "Invalid parameter: $1\nUsage: $USAGE" 1>&2; exit 1 ;; esac shift done if [ -n "$MONTH" ]; then : ${DEFMODE:=-m} : ${YEAR:=$(date +%Y)} LOGFILE="httpd/logs/log$YEAR/access.$MONTH" else : ${DEFMODE:=-d} fi cd $SERVERROOT || { echo "panic: can't change into $SERVERROOT" 1>&2; exit 1; } for server in $SERVERLIST; do $ECHO "Generating new statistics for $server" if [ -z "$LOGFILE" ]; then # use default logfile from configuration file $HA_PATHNAME $DEFMODE -3f -c $server/$HA_CONFNAME elif [ -f "$server/$LOGFILE" ]; then $ECHO "processing $SERVERROOT/$server/$LOGFILE" $HA_PATHNAME $DEFMODE -3f -c $server/$HA_CONFNAME $server/$LOGFILE elif [ -f "$server/${LOGFILE}.gz" ]; then $ECHO "processing $SERVERROOT/$server/${LOGFILE}.gz" gzcat $server/${LOGFILE}.gz | $HA_PATHNAME $DEFMODE -3f -c $server/$HA_CONFNAME - else echo "no logfile for $MONTH $YEAR of $server found" 1>&2 fi $ECHO "\n\c" done exit 0