Stale session problem

Peter Nixon listuser at peternixon.net
Tue Jan 16 16:54:30 CET 2007


On Thu 21 Dec 2006 05:41, Alan DeKok wrote:
> Cory Robson wrote:
> > Has anyone written a script or event process to monitor the update
> > packets against the users apparently online and in the event that no
> > update is received in a 20 min period (my updates are every 15 mins from
> > the NAS) create a close session event?
>
>   I don't think one has been written, but it shouldn't be too hard to
> write something that does the proper SQL SELECTs.
>
>   If you do write one, *please* submit it back, and we'll include it in
> the next release

This is so trivial to do that I am surprised that it takes up a thread on the 
mailing list :-)

We run the following from cron:

# crontab -l
0 23 * * * /usr/local/bin/radcleanunknowns

# cat /usr/local/bin/radcleanunknowns
#!/bin/sh
/bin/su postgres -c 'cd ~ && echo "" && psql -d 
radius -f /etc/radsql/drop_unkowns.sql'

# cat /etc/radsql/drop_unkowns.sql
UPDATE radacct SET acctstoptime = acctstarttime, acctsessiontime = 0 WHERE 
acctstoptime IS NULL AND (now() - acctstarttime) > '23 hour'::interval AND 
acctsessiontime IS NULL;
UPDATE radacct SET acctstoptime = (acctstarttime + 
acctsessiontime::text::interval) WHERE acctstoptime IS NULL AND (now() - 
acctstarttime - acctsessiontime::text::interval) > '1 hour'::interval ;


Just adjust it to suit your needs...

-- 

Peter Nixon
http://www.peternixon.net/
PGP Key: http://www.peternixon.net/public.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20070116/0395ebcf/attachment.pgp>


More information about the Freeradius-Users mailing list