Hi Paul
You can try this:
Be sure to define a 'Check Attribute' of 'Session-Timeout' when you make use of rlm_sqlcounter.
EG
Session-Timeout := 1200
you can then define a counter like this in the modules:
sqlcounter noresetcounter {
counter-name = Session-Timeout
check-name = Session-Timeout
reply-name = Session-Timeout
sqlmod-inst = sql
key = User-Name
reset = never
query = "SELECT SUM(AcctSessionTime) FROM radacct WHERE UserName='%{%k}'"
}
Include it in the 'authorize { }' section
EG 'noresetcounter'
rlm_sqlcounter will then take the check value defined and subtract the value of the SQL statement's result.
The newer versions of rlm_sqlcounter also lets you define the reply attribute, which can be handy to give users a data 'cap'.
It did prove to be buggy though on large values.
If you are lazy you could just grab a copy of Hotcakes, It already has these counters pre-defined and works 'out of the box' 