On 19-03-15 11:40, chenjiang wrote:
Hi! Experts
I want to achieve user traffic volume limit per month, but found there is a limit for user traffic to exceed 4Gbytes.
Below is my DB structure, you could see the "Max-Monthly-Trafficâ groupcheck attribute is 10Gbytes and it type is âvarchar", but it seems system deal it like a âinteger" type, so it cannot exceed 4Gbytes.
mysql> select * from radgroupcheck;
+----+--------------------+-----------------------+----+------------+ | id | groupname | attribute | op | value | +----+--------------------+-----------------------+----+------------+ | 25 | group2 | Max-Monthly-Traffic | := | 10737418240| +----+--------------------+-----------------------+----+------------+
3 rows in set (0.00 sec)
In FreeRADIUS debug mode, we could see that the rlm_sqlcounter âcheck_itemâ is always warpped in 4294967296 just like below:
[monthlytrafficcounter]
expand: %{sql:SELECT SUM(acctinputoctets+acctoutputoctets) FROM radacct WHERE username='lichan' AND UNIX_TIMESTAMP(acctstarttime) > '1425139200'} -> 7250810110
Change the last query to "SUM(...)/1024", divide the value in radgroupcheck by 1024 as well. This way it's less accurate, but that wouldn't matter much when comparing these kind of values. -- Herwin Weststrate