Re: Check traffic quota / rlm_sqlcounter
--- On Wed, 4/7/10, Alan DeKok <aland@deployingradius.com> wrote:
a) store traffic data in the DB when an accounting packet is received
Accounting to DB is already working.
b) check that on loging
You shouldn't need to use sqlcounter. Just a plain SELECT will do it.
Thank you for clarifying that.
Write the logic in Perl first, then convert it to the server config.
That is where it is getting though for me because I am new to Perl and SQL. Maybe some with more brains could provide some insight how to solve it. Here is my SQL select statement: SELECT (SUM(AcctInputOctets + AcctOutputOctets)) FROM radacct WHERE UserName='test' AND UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'; +-------------------------------------------+ | (SUM(AcctInputOctets + AcctOutputOctets)) | +-------------------------------------------+ | 12965354 | +-------------------------------------------+ What I would like to do is compare the returned value with another one which represents my traffic quota in bytes: SELECT Value from radcheck WHERE UserName = 'test' AND Attribute = 'Max-Octets'; +-----------+ | Value | +-----------+ | 200000000 | +-----------+ If the value of Max-Octets is exceeded, login shall be denied. Cheers, Alexander
Alexander wrote:
What I would like to do is compare the returned value with another one which represents my traffic quota in bytes:
See "man unlang" In the "authorize" section, do: if ("%{sql: SELECT ...quota ...}" <= "%{sql:SELECT ... usage ...}") { reject } Alan DeKok.
--- On Wed, 4/7/10, Alan DeKok <aland@deployingradius.com> wrote:
See "man unlang"
In the "authorize" section, do:
if ("%{sql: SELECT ...quota ...}" <= "%{sql:SELECT ... usage ...}") { reject }
Finally I got it to work. Thanks! Only drawback is that there must be traffic quota configured per user otherwise I get an access reject because of the SQL query. Is it possible to first check if there is a user traffic quota and if not fallback to the group traffic quota? Cheers, Alexander
Even If I assign values to THEattributes in hints file, some later evaluations in the default file are pretending: "Request:THEattributes not found" I think, I've misconfigured something and the radiusd simply jumps out of hints... How may I debug the processing of the hints file? Starting "radiusd -Xx" works fine: ... Fri Apr 9 18:34:25 2010 : Debug: (Loaded rlm_preprocess, checking if it's valid) Fri Apr 9 18:34:25 2010 : Debug: Module: Linked to module rlm_preprocess Fri Apr 9 18:34:25 2010 : Debug: Module: Instantiating preprocess Fri Apr 9 18:34:25 2010 : Debug: preprocess { Fri Apr 9 18:34:25 2010 : Debug: huntgroups = "/usr/local/etc/raddb/huntgroups" Fri Apr 9 18:34:25 2010 : Debug: hints = "/usr/local/etc/raddb/hints" ... receiving the a packet, I will output ... Fri Apr 9 18:34:54 2010 : Info: +- entering group authorize {...} Fri Apr 9 18:34:54 2010 : Info: ++[preprocess] returns ok Fri Apr 9 18:34:54 2010 : Info: ++[chap] returns noop ... I remember, that it has shown something like 'matched Line 17' in the past. I'm sure, editing the correct hints file: If I do a mistake in a DEFAULT line, radiusd does not load. Any Idea, how to get more output, at least for the positive matches? Thank you Stefan
would u please show me the code u used? On Fri, Apr 9, 2010 at 4:27 PM, Alexander <alexander_austria@yahoo.com>wrote:
--- On Wed, 4/7/10, Alan DeKok <aland@deployingradius.com> wrote:
See "man unlang"
In the "authorize" section, do:
if ("%{sql: SELECT ...quota ...}" <= "%{sql:SELECT ... usage ...}") { reject }
Finally I got it to work. Thanks!
Only drawback is that there must be traffic quota configured per user otherwise I get an access reject because of the SQL query.
Is it possible to first check if there is a user traffic quota and if not fallback to the group traffic quota?
Cheers, Alexander
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (4)
-
Alan DeKok -
Alexander -
Mordor Networks -
Stefan A.