ExampleThis example demonstrates, how we use rc5pstats for doing our stats using its caching feature. The script used for this is caled run.sh and shown below. Only the first time or in case we want to rebuild all stats from the scratch from all available logfiles without using any cached information, we start run.sh first . For today stats generation we simply use the already cached information from a previous run, but remove all information from today and re- read the todays logfile, only. This is done using the cronjob: 5 1,5,7,9,11,13,15,19,21,23 * * * /opt/rc5pstats/etc/run.sh daily After the day flips new entries might have been added to the old today logfile, thus we read all cached information, but remove any information from yesterday and today and than read in logfiles from yesterday and today. This is done using the cronjob: 5 3 * * * /opt/rc5pstats/etc/run.sh nightly That´s it ;-) The rc5pstats config filelogconf.file = /opt/rc5pstats/etc/md.lcf html.dir = /opt/www/htdocs/rc5/stats html.index.file = index.html html.index.include = /opt/rc5pstats/etc/news.include # we do not set this to avoid double accounting in case someone forgot # to specifiy it on the command line #log.dirs = /var/log/rc5 log.file.prefix = pproxyrc5 log.file.extension = log # we set this at commandline depending on the job to do. #log.files = #cache.dir = /var/log/rc5/cache team.name = Magdeburg team.url = http://www.linofee.org/rc/ team.id = 885184240 team.icon = md.gif email.charts = yes ip.filter.file = /opt/rc5pstats/etc/ip.filter The run.sh scriptNOTE: You must use the option -Djava.awt.headless=true if you want to run the application as a cronjob or a machine, which has no display environment (e.g. X11). #!/bin/ksh JAVA_HOME=/opt/java export JAVA_HOME RC5PSTATS=/opt/rc5pstats CONF=${RC5PSTATS}/etc/md.cf LOG_DIR=/var/log/rc5 CACHE_DIR=/var/log/rc5/cache if [ ! -x ${RC5PSTATS}/bin/rc5pstats ];then echo "Unable to execute ${RC5PSTATS}/bin/rc5pstats" exit 1 fi Usage() { echo "Usage: $0 {first|daily|nightly}" echo " " echo " first .. removes all cache files and does accounting over all" echo " logfiles in $LOG_DIR" echo " daily .. read cache files, remove accounting information" echo " for today and than add information from the today´s" echo " logfile (pproxyrc5_today_.log)." echo " nightly .. read cache files, remove accounting information" echo " for today AND yesterday and than add information" echo " from yesterdays and todays logfile" echo " (pproxyrc5_today_.log, pproxyrc5_yesterday_.log)." echo " " } if [ -z "$1" ]; then Usage exit 2 fi case $1 in first) # remove all old cache files if [ -d ${CACHE_DIR} ]; then rm -rf ${CACHE_DIR}/*.cache 2>/dev/null fi ${RC5PSTATS}/bin/rc5pstats -Dconfig.file=${CONF} \ -Dlog.dirs=${LOG_DIR} -Dcache.dir=${CACHE_DIR} \ -Djava.awt.headless=true ;; daily) ${RC5PSTATS}/bin/rc5pstats -Dconfig.file=${CONF} \ -Dcache.dir=${CACHE_DIR} -Dremove.days=today \ -Dlog.files=${LOG_DIR}/pproxyrc5_today_.log \ -Dlog.dirs=${LOG_DIR} -Dcache.dir=${CACHE_DIR} \ -Djava.awt.headless=true ;; nightly) ${RC5PSTATS}/bin/rc5pstats -Dconfig.file=${CONF} \ -Dcache.dir=${CACHE_DIR} -Dremove.days=yesterday,today \ -Dlog.files=${LOG_DIR}/pproxyrc5_yesterday_.log,${LOG_DIR}/pproxyrc5_today_.log \ -Dlog.dirs=${LOG_DIR} -Dcache.dir=${CACHE_DIR} \ -Djava.awt.headless=true ;; *) Usage exit 3 ;; esac The logging configuration file# Set root category (default) priority to DEBUG and its only appender to stderr. #log4j.rootLogger=INFO, stderr log4j.rootLogger=WARN, stderr # stderr is set to be a ConsoleAppender. log4j.appender.stderr=org.apache.log4j.ConsoleAppender # stderr uses PatternLayout. log4j.appender.stderr.layout=org.apache.log4j.PatternLayout log4j.appender.stderr.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p - %m%n The ip filter rule file10.0.0.0/8 = *.imsgroup.de 192.168.0.0/16 = *.imsgroup.de .*.t-dialin.net = *.t-dialin.net .*.pool.mediaWays.net = *.pool.mediaWays.net .*.arcor-ip.net = *.arcor-ip.net |