Session-Octets-Limit and sqlcounter

Charles charles at goma.kivu-online.com
Mon Nov 30 11:41:08 CET 2009


Do you manage to fix your problem?
Kindly share your solution. I am interested in knowing how I can configure my freeradius to limit users by both time and  max download size

e.g. 1usd for 1 hour or 20MB (whichever comes first).

charles
  ----- Original Message ----- 
  From: Hamid Reza Hasani 
  To: freeradius-users at lists.freeradius.org 
  Sent: Sunday, November 29, 2009 5:45 PM
  Subject: Session-Octets-Limit and sqlcounter


  Hi, 

  I'm using freeradius-2.1.6, and I'm going to make a download limitation for my users. I used sqlcounter module and config it as follow: 

  sqlcounter monthlydownload { 

  counter-name = "Monthly-Download-Byte" 

  check-name = "Max-Monthly-Download" 

  reply-name = "Session-Octets-Limit" 

  key = "User-Name" 

  sqlmod-inst = "sql" 

  query = "SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')" 

  reset = "monthly" 

  safe-characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /" 

  } 


  According to the log messages, it shows anything is OK: 


  rlm_sqlcounter: Sent Reply-Item for user hrh, Type=Session-Octets-Limit, value=600106145 

  ++[monthlydownload] returns ok 


  But in proceeding it shows me what it sent, and there isn't Session-Octets-Limit! as you can see bellow: 


  Sending Access-Accept of id 222 to 127.0.0.1 port 32769 

  Framed-IP-Address := 20.20.20.1 

  Framed-IP-Netmask := 255.255.255.0 

  Session-Timeout = 5460 

  Finished request 0. 


  Where is my problem? 

  more log is available at the end of message. 

  Thanks for you helps. 

  ------

  Ya Ali


  Hamid Reza Hasani




  More Log:

  Module: Linked to module rlm_sqlcounter 

  Module: Instantiating monthlydownload 

  sqlcounter monthlydownload { 

  counter-name = "Monthly-Download-Byte" 

  check-name = "Max-Monthly-Download" 

  reply-name = "Session-Octets-Limit" 

  key = "User-Name" 

  sqlmod-inst = "sql" 

  query = "SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')" 

  reset = "monthly" 

  safe-characters = "@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /" 

  } 

  rlm_sqlcounter: Reply attribute Session-Octets-Limit is number 3009 

  rlm_sqlcounter: Counter attribute Monthly-Download-Byte is number 11273 

  rlm_sqlcounter: Check attribute Max-Monthly-Download is number 11274 

  rlm_sqlcounter: Current Time: 1259506851 [2009-11-29 18:30:51], Next reset 1259613000 [2009-12-01 00:00:00] 

  rlm_sqlcounter: Current Time: 1259506851 [2009-11-29 18:30:51], Prev reset 1257021000 [2009-11-01 00:00:00] 

  Module: Checking preacct {...} for more modules to load 

  . 

  . 

  . 

  rlm_sqlcounter: Entering module authorize code 

  sqlcounter_expand: 'SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='%{User-Name}' AND AcctStartTime > FROM_UNIXTIME('1257021000')' 

  [monthlydownload] expand: SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='%{User-Name}' AND AcctStartTime > FROM_UNIXTIME('1257021000') -> SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000') 

  sqlcounter_expand: '%{sql:SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000')}' 

  [monthlydownload] sql_xlat 

  [monthlydownload] expand: %{User-Name} -> hrh 

  [monthlydownload] sql_set_user escaped user --> 'hrh' 

  [monthlydownload] expand: SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000') -> SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000') 

  [monthlydownload] expand: /usr/var/log/radius/sqltrace.sql -> /usr/var/log/radius/sqltrace.sql 

  rlm_sql (sql): Reserving sql socket id: 3 

  rlm_sql_mysql: query: SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000') 

  [monthlydownload] sql_xlat finished 

  rlm_sql (sql): Released sql socket id: 3 

  [monthlydownload] expand: %{sql:SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000')} -> 100213 

  rlm_sqlcounter: Check item is greater than query result 

  rlm_sqlcounter: Authorized user hrh, check_item=600000000, counter=100213 

  rlm_sqlcounter: Sent Reply-Item for user hrh, Type=Session-Octets-Limit, value=600106145 

  ++[monthlydownload] returns ok 

  . 

  . 

  . 

  Sending Access-Accept of id 222 to 127.0.0.1 port 32769 

  Framed-IP-Address := 20.20.20.1 

  Framed-IP-Netmask := 255.255.255.0 

  Session-Timeout = 5460 

  Finished request 0. 

  Going to the next request 

  Waking up in 4.9 seconds. 




  ________________________________________________________________ 5 free Domains with Select Hosting Plans. Get yours!

            com net org info us name biz cc tv ws mobi       



------------------------------------------------------------------------------


  -
  List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
__________________________________________________
 Buy a domain : http://www.1and1.com/?k_id=25085883
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20091130/48bbe96e/attachment.html>


More information about the Freeradius-Users mailing list