############################################################ # hrpu.sh - calculates number of Portal users for every hour # with daily totals - run from cron at 11:59 each # night # # J. David Schronce - Thu Jan 3 02:18:42 CST 2008 ########################################################### # Definitions: # Users - Users may have multiple transactions # Here they are combined into one entry # Transactions Every Servlet call is counted as a transaction. # A single mouse click could initiate multiple # servlet calls. # # An attempt is made here to standardize the web server # log directories. On my servers they have a consistant # beginning, which I call LOGDIR, followed by the Environment # name, and ending with "access.log" - which I call # LOGEXT. Hopefully you can find similarities for your # log files. # ########################################################### LOGDIR=/apps/ihs/*/logs LOGEXT=access.log ########################################################### USAGE="\nUSAGE: $0 \n" if [ $# -ne 1 ] ; then echo $USAGE exit fi DATE=`date +%d/%b/%Y` LAENV=$1 echo " Time , Users , Transactions" echo "------------- , ----- , ------------" for HOUR in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 do case $HOUR in ?) HOUR="0$HOUR";; esac echo "$HOUR:00 - $HOUR:59 , \c" grep "$DATE:$HOUR:" $LOGDIR/$LAENV.$LOGEXT \ | grep -v "\- \-" \ | awk '{print $3}' \ | tr [:upper:] [:lower:] \ | sort -u > /tmp/pu_hr.$$ echo "`cat /tmp/pu_hr.$$ | grep -v ^$ | sort -u | wc -l` , \c" grep "$DATE:$HOUR:" $LOGDIR/$LAENV.$LOGEXT | grep servlet | wc -l done echo "------------- , ----- , ------------" echo "Daily Totals , \c" grep "$DATE:" $LOGDIR/$LAENV.$LOGEXT \ | grep -v "\- \-" \ | awk '{print $3}' \ | tr [:upper:] [:lower:] \ | sort -u > /tmp/pu_day.$$ echo "`cat /tmp/pu_day.$$ | grep -v ^$ | sort -u | wc -l` , \c" grep "$DATE:" $LOGDIR/$LAENV.$LOGEXT | grep servlet | wc -l rm /tmp/pu_hr.$$ rm /tmp/pu_day.$$