2014-05-02 - Re: [GRASE-Hotspot] Is there a way to set the recurring limits to reset at say 12pm instead of 12am?

Header Data

From: Timothy White <ti***8@gmail.com>
Message Hash: c0068f9b8bf9d938a5661af33d91f33dd784951acb35b70c3afc10a8ed44a581
Message ID: <CAESLx0KQiX8UgmJdsrgyATj_XGJLvS1W+hA68N0tb1n4+cZk0Q@mail.gmail.com>
Reply To: <2814d912-18d0-4826-ac4f-2efaf9ae3f49@grasehotspot.org>
UTC Datetime: 2014-05-02 03:00:25 UTC
Raw Date: Fri, 02 May 2014 20:00:25 +1000

Raw message

On Fri, May 2, 2014 at 12:59 PM, Derek Mitchell <de***2@gmail.com>wrote:

> Hi, I have changed line 417 and it has not worked.  Here are the changes I
> made: *"my $unixtime = mktime (0, 0, 12, $mday, $mon, $year, 0, 0);"*
>
> I am trying to change the daily recurring data reset time from midnight to
> midday.  Can someone please tell me what I have done wrong and how to fix
> it.
>
>
I think you may end up needing more advanced code here.

Normally, at any time of the day, the code will return midnight of the
current day.  With your modified code, it'll return lunch time of the
current day. However, that will be in the future for the first 12 hours of
the day, which may cause issues, I'm not sure.

The actually query that is run is
https://github.com/GraseHotspot/grase-conf-freeradius/blob/master/freeradius/perl_modules/sqlcounter.conf#L33
SELECT SUM(acctinputoctets - GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)),
0))+ SUM(acctoutputoctets -GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)),
0)) FROM radacct WHERE username='%{%k}' AND UNIX_TIMESTAMP(acctstarttime) +
acctsessiontime > '%b'"
The %b is replaced with the timestamp that the function above returns.

It's been along time since I worked on this code, but I think you may find
that if %b is in the future it may have issues.

Its not something I have time to test, but those 2 locations are where you
should be looking. Run some test queries with different timestamps and see
what happens.

Good Luck

Tim

Thread