我正在使用freeradius和mysql以及choovachilli来实现强制网络门户。我目前正在尝试使用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]
如果有人能向我解释这个计数器是如何运作的,我真的很感激。我设法理解了check-name和reset的重点,但是查询选项让我很困惑。我理解查询语法和将返回值的内容,但我不明白该查询何时被调用以及谁将使用其返回值以及如何使用?
答案 0 :(得分:2)
每日会话时间的解释。