我正在使用带有 mysql 和 choovachilli 的 freeradius 来实现强制门户。我目前正在尝试使用 rlm_sqlcounter 实现日常帐户,但没有成功。这是我包含在全局配置中的配置文件:
sqlcounter dailycounter {
counter-name = 'Daily-Session-Time'
check-name = 'Max-Daily-Session'
sql_module_instance = 'sql'
key = 'User-Name'
reset = daily
query = "SELECT SUM(acctsessiontime - GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE username='%{${key}}' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'"
}
authorize {
sql
dailycounter
}
accounting {
sql
}
在 freeradius 日志中,只有这个与计数器相关的输出:
Tue Oct 6 13:02:22 2015 : Debug: Module: Linked to module rlm_expr
Tue Oct 6 13:02:22 2015 : Debug: Module: Instantiating module "expr" from file /etc/freeradius/modules/expr
Tue Oct 6 13:02:22 2015 : Debug: (Loaded rlm_counter, checking if it's valid)
Tue Oct 6 13:02:22 2015 : Debug: Module: Linked to module rlm_counter
Tue Oct 6 13:02:22 2015 : Debug: Module: Instantiating module "daily" from file /etc/freeradius/modules/counter
Tue Oct 6 13:02:22 2015 : Debug: counter daily {
Tue Oct 6 13:02:22 2015 : Debug: filename = "/etc/freeradius/db.daily"
Tue Oct 6 13:02:22 2015 : Debug: key = "User-Name"
Tue Oct 6 13:02:22 2015 : Debug: reset = "daily"
Tue Oct 6 13:02:22 2015 : Debug: count-attribute = "Acct-Session-Time"
Tue Oct 6 13:02:22 2015 : Debug: counter-name = "Daily-Session-Time"
Tue Oct 6 13:02:22 2015 : Debug: check-name = "Max-Daily-Session"
Tue Oct 6 13:02:22 2015 : Debug: reply-name = "Session-Timeout"
Tue Oct 6 13:02:22 2015 : Debug: allowed-servicetype = "Framed-User"
Tue Oct 6 13:02:22 2015 : Debug: cache-size = 5000
Tue Oct 6 13:02:22 2015 : Debug: }
Tue Oct 6 13:02:22 2015 : Debug: rlm_counter: Counter attribute Daily-Session-Time is number 3000
Tue Oct 6 13:02:22 2015 : Debug: rlm_counter: Current Time: 1444129342 [2015-10-06 13:02:22], Next reset 1444168800 [2015-10-07 00:00:00]
如果有人能向我解释这个计数器是如何工作的,我将不胜感激。我设法理解了检查名称和重置的意义,但查询选项让我感到困惑。我了解查询语法以及返回值是什么,但我不明白何时调用该查询以及谁将使用其返回值以及如何使用?