Rlm_sqlcounter - how to configure weekly reset on every Sunday?

Lee Sing Chyun singchyun at gmail.com
Mon Nov 19 18:21:11 CET 2007


Hi, I'm trying to configure a sqlcounter that is reset every Sunday 0:00AM:

        sqlcounter weeklycounter {
                counter-name = Weekly-Session-Time
                check-name = Max-Weekly-Session
                reply-name = Session-Timeout
                sqlmod-inst = sql
                key = User-Name
                reset = weekly

                # For mysql:
                query = "SELECT SUM(AcctSessionTime - \
                 GREATEST((%b - UNIX_TIMESTAMP(AcctStartTime)), 0)) \
                 FROM radacct WHERE UserName='%{%k}' AND \
                 UNIX_TIMESTAMP(AcctStartTime) + AcctSessionTime > '%b'"
        }

After that, I did a radtest. From the resulting SQL trace, I notice "%b" is
expanded as 7 days earlier than today. For instance, when running radtest on
20 Nov 2007 1:16AM (a Tuesday), "%b" gets expanded to 13 Nov 2007 0:00AM (a
Tuesday too), which is not my desired outcome.

Hence, how do I configure a sqlcounter that is reset every Sunday 0:00AM?
Thanks in advance, and sorry if there're any obvious mistakes that I have
overlooked.

-- 
sc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20071120/da9d2b8c/attachment.html>


More information about the Freeradius-Users mailing list