it is important to take your time, look and work carefully. i sent you correct counter but you did not use it. I can still see wrong query in your "dailycounter" file, use this counter. i also indicated in my mail earlier that there is something wrong in the query. You did not check it ? compare with my email i sent earlier ? this is not good. Put your little efforts as well before you can solve this problem. sqlcounter dailycounter{ counter_name = "Daily-Session-Time" check_name = "Max-Daily-Session" reply_name = "Session-Timeout" sql_module_instance = "sql" key = "User-Name" reset = "daily" cache-size = 5000 query = "SELECT IFNULL(TIME_TO_SEC(TIMEDIFF(NOW(), MIN(AcctStartTime))),0) FROM radacct WHERE UserName='%{%k}' ORDER BY AcctStartTime LIMIT 1;" } Thanks / --RM On Tue, May 13, 2014 at 8:08 AM, * <zhex900@gmail.com> wrote:
I checked, it is in one line. I have attached the sqlcounter file.
Jake He
On Tue, May 13, 2014 at 3:55 PM, Russell Mike <radius.sir@gmail.com>wrote:
Hi
On Tue, May 13, 2014 at 1:31 AM, * <zhex900@gmail.com> wrote:
Hi,
I followed your instructions. Now I get the following errors:
(2) [-sql] = ok (2) [expiration] = noop (2) [logintime] = noop (2) WARNING: pap : Auth-Type already set. Not setting to PAP (2) [pap] = noop (2) dailycounter : Entering module authorize code (2) ERROR: dailycounter : %{sql:SELECT SUM(acctsessiontime) FROM radacct WHERE username = '%{User-Name}' AND acctstarttime BETWEEN FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')} (2) ERROR: dailycounter : ^ Invalid variable expansion (2) [dailycounter] = fail (2) } # authorize = fail (2) Using Post-Auth-Type Reject
/etc/freeradius/mods-enabled/sqlcounter
sqlcounter dailycounter{ counter_name = "Daily-Session-Time" check_name = "Max-Daily-Session" reply_name = "Session-Timeout" sql_module_instance = "sql" key = "User-Name" reset = "daily" cache-size = 5000 query = "SELECT SUM(acctsessiontime) FROM radacct WHERE username = '%{${ key}}' AND acctstarttime BETWEEN FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')" }
Could you please make sure if the above query is in one line or use "\" to break the line. it is indicating some wrong expression in the query. carefully check your daily counter. it would work.
On Mon, May 12, 2014 at 11:27 PM, Russell Mike <radius.sir@gmail.com>wrote:
Do the following
STEP 1:
nano counters.conf
sqlcounter dailycounter {
counter-name = "Daily-Session-Time"
check-name = "Max-Daily-Session"
reply-name = "Session-Timeout"
sqlmod-inst = "sql"
key = "User-Name"
reset = "daily"
cache-size = 5000
query = "SELECT SUM(acctsessiontime) FROM radacct WHERE username = '%{%k}' AND acctstarttime BETWEEN FROM_UNIXTIME('%b') AND FROM_UNIXTIME('%e')"
}
STEP 2:
nano radiusd.conf
instantiate {
dailycounter
}
STEP 3:
nano sites-available/default
authorize {
dailycounter
}
STEP 4:
accounting {
sql
}
STEP 5: LOOK, THIS MUST BE *CHECK & REPLY* ITEM NOT CHECK ONLY. BOB IS ALLOWED FOR 60 MINUTES, VALUE IS IN SECONDS.
Max-Daily-Session := 3600
STEP 6: Restart Radius Daemon RM --
On Mon, May 12, 2014 at 11:28 AM, * <zhex900@gmail.com> wrote:
Hi,
I have to follow this tutorial to get the the session limit working. But looking at the debug output it seems the sql counter is not executed. No Session-Timeout is sent to NAS as well.
Accounting is working fine. I can see all the accounting information radacct time.
Here is my configuration. Please let me know if I should provide more information.
Jake He
FreeRADIUS V. 3
mods-enabled/sqlcounter
sqlcounter noresetcounter { sql_module_instance = sql #dialect = ${sql_module_instance}.dialect dialect = mysql counter_name = Daily-Session-Time check_name = Max-Daily-Session reply_name = Session-Timeout key = User-Name reset = never query = “SELECT SUM(AcctSessionTime) FROM radacct where UserName=’%{%k}’” }
sites-enabled/default:
authorize {
preprocess chap mschap suffix eap files sql pap noresetcounter }
radcheck: Max-Daily-Session:=60 for the user bob
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html