Re: Rotate or splitting up log for radius

Joe Hartley (jh@metheny.brainiac.com)
Thu, 12 Dec 96 10:51:53 EST

> I need a script which split up the main large file into smaller files
> sorted by months/year... i hope it would also deal with people who have had
> logins which span those periods.... ie they login 31st 11pm and are on till 2am
> the next day.. 1st of the month...
>

Here's a short script that I call "monthend". I run it with a cron job at
one minute before midnight on the last day of the month. The current month's
detail is moved to detailmm.yy (e.g. detail11.96). I then use the old
detail file to process the user's total usage for the month. raquick
can be found on one of the many web sites that have PortMaster scripts.

#!/bin/csh
#
# Move the detail files to their proper month.year
set DAT = `date +%m.%y`
cd /var/adm/radacct/pm1
mv detail detail$DAT
cd /var/adm/radacct/pm2
mv detail detail$DAT
#
# generate real month-end report
/etc/raddb/raquick /usr/adm/radacct/pm1/detail$DAT> /tmp/ra1
/etc/raddb/raquick /usr/adm/radacct/pm2/detail$DAT >> /tmp/ra1
date > /home/tm/acct$DAT
sort /tmp/ra1 >> /home/tm/acct$DAT ; chown tom /home/tm/acct$DAT
========================================================================
Joe Hartley - jh@brainiac.com - brainiac services, inc
PO Box 5069 : Greene, RI : 02827 - vox 401.539.9050 : fax 401.539.2070
Without deviation from the norm, "progress" is not possible. - FZappa