Hello, I would like somehow to count the online users inside the freeradius! It is better to create my own module or to modify the exist sql module???
On Mon, Jan 23, 2017 at 01:35:04PM +0200, Haviaras Kostas wrote:
Hello, I would like somehow to count the online users inside the freeradius! It is better to create my own module or to modify the exist sql module???
No users are online "inside FreeRADIUS". They are connected to your NAS. You could query your NAS to get the number of active sessions, or use one of the database modules in FreeRADIUS (likely rlm_sql) to keep track of the accounting data from your NAS. Which it does by default. Either way, there's no need to create a new module. Matthew -- Matthew Newton, Ph.D. <mcn4@leicester.ac.uk> Systems Specialist, Infrastructure Services, I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom For IT help contact helpdesk extn. 2253, <ithelp@le.ac.uk>
On 23/01/2017 11:35, Haviaras Kostas wrote:
Hello, I would like somehow to count the online users inside the freeradius!
If this is a busy server, then I suggest you should look at rlm_redis as the backend. You can create a new redis "hash" for each username, with a hash key of <session-id> and the value of <timestamp> which is the time of the most recent Start or Interim-Update record. * On receiving Start or Interium-Update, update the key: HSET acct:<username> <unique-session-id> <timenow> * On receiving Stop, delete the key: HDEL acct:<username> <unique-session-id> * At login time, use a HLEN query to see how many sessions are currently active HLEN acct:<username> All the above can be done in unlang, without writing any new modules. Plus you probably want to deal with stale sessions, where for some reason the Stop record hasn't arrived, or a Stop and Interim-Update arrived in the wrong order. Either: * Periodically scan the acct:* keyspace to look for stale sessions (where timenow is more than say 3x the accounting interim update interval from your NAS), and delete them; and/or * after every HSET/HDEL also send "EXPIRE acct:<username> numsecs". But this will only clean up stale sessions if the user doesn't have any sessions open at all. HTH, Brian.
participants (3)
-
Brian Candler -
Haviaras Kostas -
Matthew Newton