<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
        <title></title>
        <meta name="GENERATOR" content="OpenOffice.org 3.1  (Linux)">
        <style type="text/css">
        <!--
                @page { margin: 0.79in }
                P { margin-bottom: 0.08in }
        -->
        </style>

<p style="margin-bottom: 0in;"><font size="4">Hi,
</font></p>
<p style="margin-bottom: 0in;"><font size="4">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:
</font></p>
<p style="margin-bottom: 0in;">  <font size="2">sqlcounter
monthlydownload {
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">counter-name
= "Monthly-Download-Byte"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">check-name
= "Max-Monthly-Download"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">reply-name
= "Session-Octets-Limit"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">key
= "User-Name"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">sqlmod-inst
= "sql"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">query
= "SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct
WHERE         UserName='%{%k}' AND AcctStartTime >
FROM_UNIXTIME('%b')"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">reset
= "monthly"
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">safe-characters
=
"@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
/"
</font></p>
<p style="margin-bottom: 0in;">  <font size="2">}</font>
</p>
<p style="margin-bottom: 0in;">  
</p>
<p style="margin-bottom: 0in;"><font size="4"><font size="2">  </font>According to the log messages, it
shows anything is OK:
</font></p>
<p style="margin-bottom: 0in;">  
</p>
<p style="margin-bottom: 0in;">  <font size="2">rlm_sqlcounter:
Sent Reply-Item for user hrh, Type=Session-Octets-Limit,
value=600106145
</font></p>
<p style="margin-bottom: 0in;"><font size="2">++[monthlydownload]
returns ok
</font></p>
<p style="margin-bottom: 0in;"> 
</p>
<p style="margin-bottom: 0in;"><font size="4"><font size="2">  </font>But in proceeding it shows me what it
sent, and there isn't Session-Octets-Limit! as you can see bellow:
</font></p>
<p style="margin-bottom: 0in;">  
</p>
<p style="margin-bottom: 0in;">  <font size="2">Sending
Access-Accept of id 222 to 127.0.0.1 port 32769
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">Framed-IP-Address
:= 20.20.20.1
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">Framed-IP-Netmask
:= 255.255.255.0
</font></p>
<p style="margin-bottom: 0in;">        <font size="2">Session-Timeout
= 5460
</font></p>
<p style="margin-bottom: 0in;">  <font size="2">Finished
request 0.
</font></p>
<p style="margin-bottom: 0in;">  
</p>
<p style="margin-bottom: 0in;"><font size="4"><font size="2">  </font>Where is my problem?
</font></p>
<p style="margin-bottom: 0in;"><font size="4">more log is available at the end of
message.
</font></p>
<p style="margin-bottom: 0in;"><font size="4">  Thanks for you helps.
</font></p>

<p style="margin-bottom: 0in;"><font size="4">------</font></p>
<p style="margin-bottom: 0in;"><font size="4">Ya Ali</font></p>
<p style="margin-bottom: 0in;">  
</p>
<p style="margin-bottom: 0in;"><font size="4">Hamid Reza Hasani</font></p><p style="margin-bottom: 0in;"><font size="4"><br></font>
</p>
<p style="margin-bottom: 0in;"><font size="4">More Log:</font></p>
<p style="margin-bottom: 0in;"><font size="4">  <font size="2">Module: Linked to module
rlm_sqlcounter
</font></font></p>
<p style="margin-bottom: 0in;"><font size="2"> Module: Instantiating monthlydownload
</font></p>
<p style="margin-bottom: 0in;"><font size="2">  sqlcounter monthlydownload {
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        counter-name =
"Monthly-Download-Byte"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        check-name =
"Max-Monthly-Download"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        reply-name =
"Session-Octets-Limit"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        key = "User-Name"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        sqlmod-inst = "sql"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        query = "SELECT
SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE        
UserName='%{%k}' AND AcctStartTime > FROM_UNIXTIME('%b')"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        reset = "monthly"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        safe-characters =
"@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_:
/"
</font></p>
<p style="margin-bottom: 0in;"><font size="2">  }
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Reply attribute
Session-Octets-Limit is number 3009
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Counter attribute
Monthly-Download-Byte is number 11273
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Check attribute
Max-Monthly-Download is number 11274
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Current Time:
1259506851 [2009-11-29 18:30:51], Next reset 1259613000 [2009-12-01
00:00:00]
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Current Time:
1259506851 [2009-11-29 18:30:51], Prev reset 1257021000 [2009-11-01
00:00:00]
</font></p>
<p style="margin-bottom: 0in;"><font size="2"> Module: Checking preacct {...} for
more modules to load
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Entering module
authorize code
</font></p>
<p style="margin-bottom: 0in;"><font size="2">sqlcounter_expand:  'SELECT
SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE        
UserName='%{User-Name}' AND AcctStartTime >
FROM_UNIXTIME('1257021000')'
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[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')
</font></p>
<p style="margin-bottom: 0in;"><font size="2">sqlcounter_expand:  '%{sql:SELECT
SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE        
UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000')}'
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload] sql_xlat
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload]       expand:
%{User-Name} -> hrh
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload] sql_set_user escaped
user --> 'hrh'
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[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')
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload]       expand:
/usr/var/log/radius/sqltrace.sql ->
/usr/var/log/radius/sqltrace.sql
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sql (sql): Reserving sql socket id:
3
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sql_mysql: query:  SELECT
SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE        
UserName='hrh' AND AcctStartTime > FROM_UNIXTIME('1257021000')
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload] sql_xlat finished
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sql (sql): Released sql socket id:
3
</font></p>
<p style="margin-bottom: 0in;"><font size="2">[monthlydownload]       expand:
%{sql:SELECT SUM(AcctOutputOctets+AcctInputOctets) FROM radacct WHERE
        UserName='hrh' AND AcctStartTime >
FROM_UNIXTIME('1257021000')} -> 100213
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Check item is greater
than query result
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Authorized user hrh,
check_item=600000000, counter=100213
</font></p>
<p style="margin-bottom: 0in;"><font size="2">rlm_sqlcounter: Sent Reply-Item for
user hrh, Type=Session-Octets-Limit, value=600106145
</font></p>
<p style="margin-bottom: 0in;"><font size="2">++[monthlydownload] returns ok
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">Sending Access-Accept of id 222 to
127.0.0.1 port 32769
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        Framed-IP-Address :=
20.20.20.1
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        Framed-IP-Netmask :=
255.255.255.0
</font></p>
<p style="margin-bottom: 0in;"><font size="2">        Session-Timeout = 5460
</font></p>
<p style="margin-bottom: 0in;"><font size="2">Finished request 0.
</font></p>
<p style="margin-bottom: 0in;"><font size="2">Going to the next request
</font></p>
<p style="margin-bottom: 0in;"><font size="2">Waking up in 4.9 seconds.
</font></p>
<p style="margin-bottom: 0in;">
</p>