4

I am creating a usage stats web-page that will show current online users and have a historical graph of users at a given time/date.

Is there a function in freeradius to easily grab the number of current connected users I can then dump into a database for my webpage to use in the usage chart?

The only solution I have found is reading the acct table with a cron-job every 15 minutes, I'm hoping there is a better solution I haven't found yet.

James Cox
  • 41
  • 1
  • 2

3 Answers3

2

if you want to use it from radius side then you have to use cron jobs,because radius cant give you historical data of time interval, it collects data based on session, but you can get current online user data from radacct table

SELECT username FROM radacct WHERE acctstoptime IS NULL;

Or you can use linux command "radwho" reference: .official freeradius doc

And for historical data you can use router's api like Mikrotik MRTG report or you can go with some SNMP based NMS (Like [LibreNMS])

1

No, freeradius doesn't track the state of accounting sessions internally. You need to write the accounting data to a database, which you can then query to get number of concurrent sessions at a given point.

There's some example SQL queries in this question that may help you: Calculate number of concurrent events in SQL

If you didn't want to use complex SQL you could poll the database every few minutes, and get a count of sessions with no stop time (still active), then record the count in a separate table.

Community
  • 1
  • 1
Arran Cudbard-Bell
  • 5,912
  • 2
  • 26
  • 48
1

SELECT username from radacct WHERE username LIKE '%@wireless%' AND acctstoptime IS NULL GROUP BY username

kay
  • 337
  • 3
  • 7