Get number of users logged in via mySQL

Alan DeKok aland at
Mon Dec 17 14:12:26 CET 2018

On Dec 17, 2018, at 7:24 AM, Renato Sousa <rensousa at> wrote:
> I would like to get the number of logged in users on freeradius server
> (3.0.12).

  Count the rows in the radacct which have a NULL acctstoptime.

> Looking at the mySQL accounting table, the connections with the NULL value
> for the acctstoptime field, I see some connections with the same user and
> even  device mac-address with the NULL acctstoptime field.

  The server just records what the NAS sends it.  If the NAS doesn't tell the server those sessions are closed, then the server doesn't know.

> How to get this precise value through mySQL tables?

  Fix that NAS so that it closes old sessions.

  The server isn't magic.  It only knows what the NAS sends it.  If the NAS tells it that the same user logged in 4 times, well, why would FreeRADIUS think any differently?

> How to delete these open sessions?

  SQL statements.

  Alan DeKok.

More information about the Freeradius-Users mailing list