Listing 2 - Squid Report cron shell script example
#!/bin/sh
#
#	SquidReport.sh
#
#	Example shell script to perform analysis on squid log files
#	and rename files for current year and month.  Assuming all
#	the logs are kept in one file.  In reality, there would be
#	several weekly or daily log files, possibly compressed.
#
SQDIR=/opt/local/squid
SQLOG=$SQDIR/logs
SQWEB=$SQDIR/htdocs
SQBIN=$SQDIR/bin
#
SQACC=$SQLOG/access.log
SQPRM=$SQBIN/PerfStat.pl
SQRPT=$SQWEB/perf.html
#
SQDAT=`date -u "%Y.%m"`
#
#	change graphic file names function
#
fix_graphics()
{
  for i in CHpie CVpie DHpie DVpie PApie PVpie THpie TVpie RThist VDhist
  do
    if [ -s $SQWEB/${i}.png ]; then
      mv $SQWEB/${i}.png $SQWEB/${i}_${SQDAT}.png
    else
      echo "error: image file [$i] missing or empty"
    fi
  done
  if [ -s $SQRPT ]; then
    sed "s/\.png/_${SQDAT}\.png/" < $SQRPT > ${SQRPT%\.html}_${SQDAT}.html
    rm $SQRPT
  else
    echo "error: report file [$SQRPT] missing or empty"
  fi
}
#
#	main
#
cd $SQWEB
cat $SQLOG | $SQPRM > $SQRPT && fix_graphics
#

