Does freeradius support considering a session as ended if enough accounting packets are missed?
I'm running FreeRADIUS Version 2.1.12. I've searched online, and haven't found anything on the subject that definitively says. Does freeradius support marking a session as ended/stopped if enough accounting packets are missed? One thing I did consider is that if not, I could try building a script that runs frequently, looking for sessions that have no accounting in the last X minutes, and changes the session to being ended (I think radzap is the tool for this, but I could be wrong). Of course, the less weird scripts I make (and have to come back and figure out what "clever" thing I did in 3 years), the better. -- Erik Andersen Eastern Oregon Net, Inc
On 17 Sep 2014, at 14:26, Erik Andersen <eandersen@eoni.com> wrote:
I'm running FreeRADIUS Version 2.1.12.
I've searched online, and haven't found anything on the subject that definitively says. Does freeradius support marking a session as ended/stopped if enough accounting packets are missed?
One thing I did consider is that if not, I could try building a script that runs frequently, looking for sessions that have no accounting in the last X minutes, and changes the session to being ended (I think radzap is the tool for this, but I could be wrong). Of course, the less weird scripts I make (and have to come back and figure out what "clever" thing I did in 3 years), the better.
No radzap isn't the tool, that's for kicking users off via SNMP. There's no bundled utility to do this, and it's not supported directly by the SQL module. In v3.0.x the default schema does include an acctupdatetime which records the last time a start or interim was received for the session. That can be used to identify stale sessions if you know what the interim interval should be. If you want to get really fancy you can write something to create something that calls radclient to generate fake stop packets, but most people just use an sql UPDATE query to close out stale sessions periodically, and just run that with cron. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
On 17 Sep 2014, at 14:38, Arran Cudbard-Bell <a.cudbardb@freeradius.org> wrote:
On 17 Sep 2014, at 14:26, Erik Andersen <eandersen@eoni.com> wrote:
I'm running FreeRADIUS Version 2.1.12.
I've searched online, and haven't found anything on the subject that definitively says. Does freeradius support marking a session as ended/stopped if enough accounting packets are missed?
One thing I did consider is that if not, I could try building a script that runs frequently, looking for sessions that have no accounting in the last X minutes, and changes the session to being ended (I think radzap is the tool for this, but I could be wrong). Of course, the less weird scripts I make (and have to come back and figure out what "clever" thing I did in 3 years), the better.
No radzap isn't the tool, that's for kicking users off via SNMP.
Ah nope, that's something different. radzap is for querying the session db (which is not the same as the radacct table), and sending fake stops. Arran Cudbard-Bell <a.cudbardb@freeradius.org> FreeRADIUS development team FD31 3077 42EC 7FCD 32FE 5EE2 56CF 27F9 30A8 CAA2
Erik Andersen wrote:
I've searched online, and haven't found anything on the subject that definitively says. Does freeradius support marking a session as ended/stopped if enough accounting packets are missed?
No. You need to run a script to clean up the database. Alan DeKok.
(Response below) On 09/18/2014 09:47 AM, Alan DeKok wrote:
Erik Andersen wrote:
I've searched online, and haven't found anything on the subject that definitively says. Does freeradius support marking a session as ended/stopped if enough accounting packets are missed?
No. You need to run a script to clean up the database.
Alan DeKok.
(I've upgraded to 3.04 since asking this question, and built a script that finds, using MySQL, stuff that has missed a few interim updates, and then fakes an end of session accounting packet using radclient). If I'm using the radacct table in MySQL, do I sradutmp/radutmp to still have concurrent sessions checks? Also, is there somewhere that lists what variables are available for the SQL queries? I'd like to collect the Framed-IPv6-Prefix (and when our NAS's eventually get support for sending it, Delegated-IPv6-Prefix). Thanks, Erik Andersen
Erik Andersen wrote:
(I've upgraded to 3.04 since asking this question, and built a script that finds, using MySQL, stuff that has missed a few interim updates, and then fakes an end of session accounting packet using radclient).
If it's useful... contribute it back.
If I'm using the radacct table in MySQL, do I sradutmp/radutmp to still have concurrent sessions checks?
You don't need radutmp for concurrent session checks.
Also, is there somewhere that lists what variables are available for the SQL queries? I'd like to collect the Framed-IPv6-Prefix (and when our NAS's eventually get support for sending it, Delegated-IPv6-Prefix).
Any attribute is allowed in SQL queries. But... the attribute has to exist in a RADIUS packet, OR have it's value set via an "update" statement, other module, etc. There are no magical limitations on attributes in SQL queries. In version 3, if the server starts, the SQL query is fine. If the server doesn't start, you've referenced an attribute which doesn't exist. Alan DeKok.
On 09/22/2014 12:23 PM, Alan DeKok wrote:
Erik Andersen wrote:
(I've upgraded to 3.04 since asking this question, and built a script that finds, using MySQL, stuff that has missed a few interim updates, and then fakes an end of session accounting packet using radclient).
If it's useful... contribute it back.
Here's what I have (python3): import mysql.connector from mysql.connector import errorcode import tempfile import subprocess import os dbsettings = { 'user' : 'radius', 'password' : 'yourpassword', 'host' : '127.0.0.1', 'database' : 'radius', 'raise_on_warnings' : True } try: cnx = mysql.connector.connect(**dbsettings) except mysql.connector.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: print("Something is wrong with your user name or password") elif err.errno == errorcode.ER_BAD_DB_ERROR: print("Database does not exists") else: print(err) cursor = cnx.cursor() # Create a temporary file and write the cleanup script to it tempf = tempfile.NamedTemporaryFile(delete=False, mode="w") cursor.execute('select username, acctsessionid, nasipaddress, nasportid, acctinputoctets, acctoutputoctets, acctsessiontime from radacct where (acctupdatetime not between (NOW()-INTERVAL 10 MINUTE) and NOW()) and acctstoptime is null;') for stalesession in cursor: tempf.write('''User-Name = "{}"\nAcct-Session-Id = "{}"\nAcct-Status-Type = Stop\nNAS-IP-Address = {}\nNAS-Port = {}\nAcct-Terminate-Cause = NAS-Error\nAcct-Input-Octets = {}\nAcct-Output-Octets = {}\nAcct-Session-Time = {}\n\n'''.format(*stalesession)) tempf.close() subprocess.check_call(['radclient', '-f', tempf.name, '127.0.0.1:1646', 'acct', 'yourpassword']) # And then clean up the temporary file os.unlink(tempf.name) cnx.close()
Any attribute is allowed in SQL queries. But... the attribute has to exist in a RADIUS packet, OR have it's value set via an "update" statement, other module, etc.
Some of our PPPoE servers would not send the attribute, some would. I'm not sure what you mean by setting the value by an update statement. Could you give an example of how to do this? Ideally, I would like to save it if it exists, and if not, just insert a NULL or empty string.
Erik Andersen wrote:
I'm not sure what you mean by setting the value by an update statement.
The "update" sections allow you to set attributes. This is documented.
Could you give an example of how to do this? Ideally, I would like to save it if it exists, and if not, just insert a NULL or empty string.
See the existing SQL accounting queries. They do this lots. See also "man unlang". Look for "Conditional Syntax". Alan DeKok.
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Erik Andersen