(RADIATOR) SQLRecoveryFile "fixed" ?

Jason Godsey jason at corp.fidalgo.net
Tue Jan 11 12:13:03 CST 2005


I'd like to see the documentation changed to reflect that 
SQLRecoveryFile simply won't work w/ MySQL :)

I wasn't given a good solution to this, and figured I was the only person who cared.

Since you have now asked, I just wrote a pickup script that you can call from cron
every 5 minutes or so to pickup missed accounting records.

I haven't tested this, so please just use it as an idea.  I'm sure there are other people
on the list who can fix it up.

(%L being /home/radiator/log for me.)
AcctFailedLogFileName %L/sqlmissed/%t.%s.txt
AcctLogFileFormat "%{User-Name}","%{Timestamp}","%{Acct-Status-Type}","%{Acct-Sessision-Time}"

--- acctpickup.pl ---
#!/usr/bin/perl
# acctpickup.pl v1 Import radiator radius accounting files that were 
missed by MySQL being unavailable.
# Copyright (C) 2005 Lanny Jason Godsey
use DBI;
$dsn = "DBI:mysql:database=radius;";
$dbh = DBI->connect($dsn, 'radiator', 'password') or die "Could not 
connect to database: " . DBI->errstr . "\n";
# no need to try importing if database is still down :)
$missed = "/home/radiator/log/sqlmissed";
$done = "$missed/done";
$error = "$missed/error";
$tmpdir = "$missed/tmp$$";
@filelist=<$missed/*.txt>;

if ($#filelist>=0) {
    if ( ! -d "$done" ) { mkdir($done); }
    if ( ! -d "$error" ) { mkdir($error); }
    if ( -d "$tmpdir" ) { die "$tmpdir exists\n"; }
    mkdir($tmpdir);
    foreach $file (@filelist) {  # this and next loop could be combined
        $file =~ s/^$missed\///; # but I guess the faster I move the files
        print "$file\n";         # the fewer race conditions.
        rename("$missed/$file", "$tmpdir/$file");
    }
    foreach $file (@filelist) {
        $file =~ s/^$missed\///;
        $query = "load data infile '$tmpdir/$file' into table accounting";
        $sth = $dbh->prepare($query);
        if ($sth->execute) {
            rename("$tmpdir/$file", "$done/$file");
        } else {
            print "Error importing $error/$file\n";
            rename("$tmpdir/$file", "$error/$file");
        }
    }
    rmdir($tmpdir) or die "Error removing $tmpdir\n";
}

$dbh->disconnect();

----- end -----

Ray Van Dolson wrote:

>http://www.open.com.au/archives/radiator/2004-03/msg00157.html
>
>Just curious if this was ever addressed... I'm running into this problem now
>(Radiator 3.11). If I restart my MySQL server, the records generated in the
>SQLRecoveryFile contain the integer values only...
>
>Guess it's not a huge priority--just trying to handle a quick MySQL restart
>without losing accounting records.
>
>Ray
>
>--
>Archive at http://www.open.com.au/archives/radiator/
>Announcements on radiator-announce at open.com.au
>To unsubscribe, email 'majordomo at open.com.au' with
>'unsubscribe radiator' in the body of the message.
>  
>

--
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list