RC5 Proxy Stats 
Bovine RC5-64 Links


This 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 file

logconf.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 script

NOTE: 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).


export JAVA_HOME





if [ ! -x ${RC5PSTATS}/bin/rc5pstats ];then
	echo "Unable to execute ${RC5PSTATS}/bin/rc5pstats"
	exit 1

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
	exit 2

case $1 in
		# remove all old cache files
		if [ -d ${CACHE_DIR} ]; then
			rm -rf ${CACHE_DIR}/*.cache 2>/dev/null
		${RC5PSTATS}/bin/rc5pstats -Dconfig.file=${CONF} \
		-Dlog.dirs=${LOG_DIR} -Dcache.dir=${CACHE_DIR} \
		${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} \
		${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} \
		exit 3

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. 

# stderr uses PatternLayout.
log4j.appender.stderr.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p - %m%n

The ip filter rule file = *.imsgroup.de = *.imsgroup.de
.*.t-dialin.net = *.t-dialin.net
.*.pool.mediaWays.net = *.pool.mediaWays.net
.*.arcor-ip.net = *.arcor-ip.net

Valid XHTML 1.0! SourceForge Logo Valid CSS!