I'm new to Freeradius. My NAS is StrongSwan and seems to be supporting CoA. I also have the sql accounting mod enabled, which allows me to count the octets.
There are many tutorials about how to count the session time of a user and action a session-timeout once the time is over. But virtually there is nothing I could find that explains how to count the user's data usage and disconnect him after let say 100 KB of monthly usage.
vim /etc/freeradius/mods-enabled/sqlcounter
sqlcounter totaldatacounter {
sql_module_instance = sql
dialect = ${modules.sql.dialect}
counter_name = Max-Capacity
check_name = Acct-Output-Octets
reply_name = Session-Timeout
key = User-Name
reset = monthly
query = "SELECT ((SUM(`acctinputoctets`)+SUM(`acctoutputoctets`))) FROM radacct WHERE `username`='%{${key}}' AND Month(acctstoptime)=(Month(NOW())) AND Year(acctstoptime)=Year(NOW())"
}
When I run the query above for the given user I get the following data usage: 76827648
This is more than my limit of 100000
set in radcheck
table:
INSERT INTO `radcheck` (`id`, `username`, `attribute`, `op`, `value`)
VALUES
(3, '0799a559-1426-478a-b46a-a33f1198cd24', 'Acct-Output-Octets', ':=', '100000');
So why am still able to connect?
I have a pastebin here of the freeradius -X
logfile.