#!/bin/sh accdir=${1:-/www/log} maxdir=`expr ${2:-500} \* 1024` # 1024 for MB to KB ls="ls" lsopts="-1skd" footer='

Back one page  Back to proxy management page

' logo='

iMimic DataReactor Log Summary

'"$footer" set -- `uname -a` if [ $1 = "SunOS" ]; then ls="/usr/ucb/ls" # For Solaris, be careful to use BSD-compat ls fi cd ${accdir} # this awk script appears repeatedly below, but portability # across multiple shells doesn't seem to allow an abstraction of it, # so the code just gets cloned over and over size=`${ls} ${lsopts} acc* 2>/dev/null | \ awk 'BEGIN {sum=0} {sum += $1} END {print sum}'` set -- `ls -tr acc*` while [ $size -gt ${maxdir} -a $# -gt 1 ]; do rm -f $1 shift size=`${ls} ${lsopts} acc* 2>/dev/null | \ awk 'BEGIN {sum=0} {sum += $1} END {print sum}'` done; while true; do read logfile sumfile gziplevel machine user password remotedir if [ $? -ne 0 ]; then exit 0; # proxy must have quit fi size=`${ls} ${lsopts} acc* 2>/dev/null | \ awk 'BEGIN {sum=0} {sum += $1} END {print sum}'` set -- `ls -tr acc*` while [ $size -gt ${maxdir} -a $# -gt 1 \ -a $1 != $logfile -a $1 != ${accdir}/${logfile} ]; do rm -f $1 shift size=`${ls} ${lsopts} acc* 2>/dev/null | \ awk 'BEGIN {sum=0} {sum += $1} END {print sum}'` done; if [ $sumfile != "/dev/null" ]; then nice -19 /usr/local/prox/logsummarize -w -n -d 100 -r 100 \ -P 30 -t 20 -s -l "${logo}" -F "${footer}" \ ${logfile} > ${sumfile} 2>/dev/null || \ rm -f ${sumfile} fi if [ $gziplevel -gt 0 ]; then nice -19 gzip -${gziplevel} ${logfile} && logfile=${logfile}.gz; fi if [ $machine != "N/A" ]; then ftp -n $machine << EOF user $user $password cd $remotedir put ${logfile} close EOF fi done