在FreeRADIUS 3.0.1 中配置月流量限制功能,在/etc/raddb/mods-available/sqlcounter中加入:
sqlcounter monthlytrafficcounter {
sql_module_instance = sql
counter_name = Monthly-Traffic
check_name = Max-Monthly-Traffic
reply_name = Monthly-Traffic-Limit
key = User-Name
reset = monthly
query = "SELECT SUM(acctinputoctets + acctoutputoctets) DIV 1024 FROM radacct \ WHERE UserName='%{${key}}' AND UNIX_TIMESTAMP(AcctStartTime) > '%b'"
}
报错:'%b' Invalid variable expansion 请指教!@AidenZhang
%b这个变量没有在FreeRADIUS里面定义,参考https://github.com/FreeRADIUS/freeradius-server/blob/0a0e2076b0d1f7f1e9eae80e6437b71493b82672/doc/configuration/variables.rst
Variable | Description | ProperEquivalent |
---|---|---|
%a | Protocol(SLIP/PPP) | %{Framed-Protocol} |
%c | Callback-Number | %{Callback-Number} |
%d | requestday(DD) | |
%f | FramedIPaddress | %{Framed-IP-Address} |
%i | CallingStationID | %{Calling-Station-Id} |
%l | requesttimestamp | |
%m | requestmonth(MM) | |
%n | NASIPaddress | %{NAS-IP-Address} |
%p | Portnumber | %{NAS-Port} |
%s | Speed(PW_CONNECT_INFO) | %{Connect-Info} |
%t | requestinctimeformat | |
%u | Username | %{User-Name} |
%A | radacct_dir | %{config:radacctdir} |
%C | clientname | |
%D | requestdate(YYYYMMDD) | |
%G | requestminute | |
%H | requesthour | |
%I | requestID | |
%L | radlog_dir | %{config:logdir} |
%M | MTU | %{Framed-MTU} |
%R | radius_dir | %{config:raddbdir} |
%S | requesttimestampinSQLformat | |
%T | requesttimestampindatabaseformat | |
%U | StrippedUsername | %{Stripped-User-Name} |
%V | Request-Authenticator(Verified/None) | |
%v | ServerVersion | |
%Y | requestyear(YYYY) | |
%Z | Allrequestattributesexceptpassword(musthaveabigbuffer) |
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。