Session-Octets-Limit and sqlcounter
Hamid Reza Hasani
hr.hasani at gmail.com
Sun Nov 29 16:45:35 CET 2009
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20091129/cad031ee/attachment.html>
More information about the Freeradius-Users
mailing list