X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-sqlradius-radacctd;h=7b2d04dc7348977be8e5dfd512ed1e7d6f9b3eea;hp=d66c875b95e52dad5300b8d7438483f40a9da95b;hb=aed8ec35ccb9cdeb7ea0cb6ff2946f9d83d582f6;hpb=22095d167d138ae7561b01d5cfbf4df5ae73a4c8 diff --git a/FS/bin/freeside-sqlradius-radacctd b/FS/bin/freeside-sqlradius-radacctd index d66c875b9..7b2d04dc7 100644 --- a/FS/bin/freeside-sqlradius-radacctd +++ b/FS/bin/freeside-sqlradius-radacctd @@ -4,11 +4,12 @@ use strict; use vars qw( @part_export ); use subs qw(myshutdown); use POSIX qw(:sys_wait_h); -use IO::File; +#use IO::File; use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm); use FS::UID qw(adminsuidsetup); #forksuidsetup driver_name dbh myconnect); use FS::Record qw(qsearch); # qsearchs); use FS::part_export; +use FS::part_export::sqlradius; #use FS::svc_acct; #use FS::cust_svc; @@ -23,20 +24,16 @@ drop_root(); adminsuidsetup $user; -logfile( "/usr/local/etc/freeside/sqlradius-radacctd-log.". $FS::UID::datasrc ); +logfile( "%%%FREESIDE_LOG%%%/sqlradius-radacctd-log.". $FS::UID::datasrc ); daemonize2(); #-- -@part_export = - qsearch('part_export', { 'exporttype' => 'sqlradius' } ); -push @part_export, - qsearch('part_export', { 'exporttype' => 'sqlradius_withdomain' } ); +my @part_export = FS::part_export::sqlradius->all_sqlradius_withaccounting(); -@part_export = grep { ! $_->option('ignore_accounting') } @part_export; - -die "no sqlradius or sqlradius_withdomain exports without ignore_accounting" +die "no sqlradius, sqlradius_withdomain, radiator or phone_sqlradius exports". + " without ignore_accounting" unless @part_export; while (1) { @@ -58,7 +55,7 @@ while (1) { adminsuidsetup($user); #get our own db handle until ( sigint || sigterm ) { - $part_export->update_svc_acct(); + $part_export->update_svc(); sleep 1; } @@ -121,20 +118,24 @@ freeside-sqlradius-radacctd - Real-time radacct import daemon =head1 DESCRIPTION -Imports records from an the SQL radacct tables of all sqlradius and -sqlradius_withdomain exports (except those with the ignore_accounting flag) and -updates the svc_acct.seconds for each account. Runs as a daemon and updates -the database in real-time. +Imports records from an the SQL radacct tables of all sqlradius, +sqlradius_withdomain and radiator exports (except those with the +ignore_accounting flag) and updates the following fields in svc_acct (see +L) for each account: last_login, last_logout, seconds, +upbytes, downbytes, totalbytes. Runs as a daemon and updates the database +in real-time. B is a username added by freeside-adduser. =head1 RADIUS DATABASE CHANGES +In 1.7.4+, freeside-upgrade should have taken care of these changes already. + ALTER TABLE radacct ADD COLUMN FreesideStatus varchar(32) NULL; If you want to ignore the existing accountg records, also do: -UPDATE TABLE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL; +UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL; =head1 SEE ALSO