This is a what I did:
Sqlcounter.conf:
sqlcounter volumelimit {
counter-name = Octets-Total
check-name = Max-Octets
sqlmod-inst = sql
key = User-Name
reset = monthly
# This query will calculate the total volume used
query = "SELECT (SUM(AcctInputOctets)
+SUM(AcctInputGigawords * 2147483648) +SUM(AcctOutputOctets)
+SUM(AcctOutputGi
gawords * 2147483648)) / 1048576 FROM radacct WHERE UserName = '%{%k}'
AND AcctStartTime > FROM_UNIXTIME('%b')"
}
If you want daily resets, just use reset = daily instead of monthly
In your radiusd.conf put:
$INCLUDE ${confdir}/sqlcounter.conf
And in your authorize section put: volumelimit.
Do:
echo "ATTRIBUTE Max-Octets 3000 integer" >>
/etc/freeradius/dictionary
The Max-Octets are in MB (to workaround the limit of a signed integer)
The attribute can be set in the radreply or radgroupreply
Be aware that you need the experimental modules to be compiled in. If
you run debian I have precompiled packages
Kind Regards
--
Jonathan De Graeve
Network/System Administrator
Imelda vzw
Informatica Dienst
015/50.52.98 |