Re: Rotating radius Logs

Dave Kennedy (davek@www.muscle.net)
Thu, 7 Aug 1997 21:43:22 -0400 (EDT)

Steven P. Crain writes...
> On Thu, 7 Aug 1997, Alex Ponnath wrote:
> > is there a way to setup radius to automaticly rotate the accounting logs on
> > a daily basis ?? If so where can i find information on how to do this ???
> >
> > If not has anybody writen a script which does this ?? If so is it publicly
> > avail. ??
>
> You can just mv the file. Make sure you wait a little after moving it
> before compressing it, since the daemon might be in the middle of writing
> the last entry. Whatever you use to rotate your other logs should work
> fine.

What I use is below. It uses a program I wrote years ago, pfdate,
that works like the unix date command with the addition that it
accepts two addtional options '-p' and '-f' -- past and future,
respectively. You can get pfdate.c from
ftp://ftp.muscle.net/pub/src/pfdate.c or I can e-mail it to you if you
want.

Good luck,
davek

#!/bin/ksh
# $Id: monthend,v 1.1 1997/03/01 04:38:11 root Exp $
########################################################################
#
# SYNOPSIS
# monthend
#
# DESCRIPTION
# Monthend processes the RADIUS detail file in preparation for
# monthly billing. It is expected to be run the first day of each
# month.
#
# 7/31/96 - Right now it just moves the detail file to a new name
#
# HISTORY
# Written 7/96 davek
#
########################################################################

export PATH=$PATH:/usr/local/bin

RADDIRS="/usr/adm/radacct/pm1"

NEWNAME=detail-$(pfdate -p 1 '+%y%m')

set -x
# Move the currently active detail file to detail-YYMM
for i in $RADDIRS
do
cd $i
mv detail $NEWNAME
done
set +x

-- 
| Dave Kennedy (davek@muscle.net)             Voice: 770-368-1514 |
| Multi-User Systems, Inc.      Putting MUSCLE in Internet Access |