deletestalesessions
Marinko Tarlac
mangia81 at gmail.com
Sat Jan 24 20:50:12 CET 2009
I have another solution...
Add one field at the end of radacct table (LastUpdate for example), and
choose datetime as a type.
Edit default queries in dialup.conf (FR 2.x) od sql.conf (FR < 2.x)
and add '%S' in all update and insert queries. Now you will have the
date and time from the last update and you can calculate which session
was stalled. (for example, if you Interim-Update interval is 5 minutes
and LastUpdate was 20min. from now, you can close session with cron script.
PHP for example:
$last_update = 10; // time in min
$this_moment = date ("Y-m-d H:i:s");
$close_sessions = mysql_query ("UPDATE radacct SET
AcctTerminateCause='Stalled-Session', AcctStopTime = AcctStartTime +
INTERVAL AcctSessionTime SECOND WHERE AcctStopTime = '0000-00-00
00:00:00' AND Vrijeme < '$this_moment' - INTERVAL '$last_update' MINUTE
AND LastUpdate != '0000-00-00 00:00:00'") or die("Ops, I can't do
anything...");
Beware, I'm using old sql schema so you can see that opened sessions in
my database has value 0000-00-00 00:00:00 and by default in 2.x version
is NULL.
You need to tune up this options because it will depend from connection
between your NAS(es) and radius server. If you have bad link, set up
updates more often and cron script can check this on every 3 minutes.
For example, if your cron script starts every 2 minutes, you have
updates on every 2 min and $last_update = 11;, script will close the
session after 5-6 checks and it means your session wasn't updated in
last 5-6 Interim-Updates and it is good idea to close it :)
Maybe I made a mistake in this calculations (working during last 24hrs)
but you'll probably get the point.
tnt at kalik.net wrote:
>> I would like to have more informations about the deletestalesessions
>> option of rlm_sql.
>>
>> - What does it do?
>> - What's its behaviour?
>> - How does it achieve what it does?
>>
>>
>
> It's used with Simultaneous-Use checking. If checkrad script discovers a
> stale session (there is an open session for the user in radius database
> but NAS doesn't have him on that port) it can be removed (so it
> doesn't create the same situation when user connects next time).
>
> Ivan Kalik
> Kalik Informatika ISP
>
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
>
>
More information about the Freeradius-Users
mailing list