Script to archive radacct table
Barry O'Donovan
mail at barryodonovan.com
Mon Jul 3 13:00:27 CEST 2006
Folks,
I just wrote a PHP (sorry!) CLI script to archive completed radacct
session data that's older than the current month and last month to a
separate database.
As the radacct table grows in size, INSERTs, UPDATEs and DELETEs take
longer as the data and index file sizes grow. SELECTs also take longer for
the same reasons.
While the script archives complete sessions older than the current month
and past month, this can be amended to today and yesterday, this week and
last week, etc easily enough.
Note that only complete sessions are moved. This script should run nightly
to catch recently closed sessions that were not caught in the "big move"
at the start of a new month. Record dates are determined by the
AcctStopTime field by default.
A MySQL merge table is used to make searching on the archived records
easy. The records are archived to a different database and the merge does
not include the live radacct. This was a decision I made but others can do
as they choose - a merge can include table from different databases as of
MySQL 4.1.1.
For more information please see:
http://www.barryodonovan.com/development/other/radacct_archive/
Comments, updates, patches, suggestions, etc all gratefully appreciated.
Suggestions on including this (after making it somewhat more generic) in
the radacct bin tree would be appreciated.
- Barry
More information about the Freeradius-Users
mailing list