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

Header Data

From: Derek Mitchell <de***2@gmail.com>
Message Hash: 5860d7d0508882c59809310a77b9fddb5e37ac97cd178c1c4596efa6bbb1a2b8
Message ID: <e32ed593-fcb2-45f1-ab2f-b7e70b86da6d@grasehotspot.org>
Reply To: <CAESLx0KQiX8UgmJdsrgyATj_XGJLvS1W+hA68N0tb1n4+cZk0Q@mail.gmail.com>
UTC Datetime: 2015-01-11 23:58:39 UTC
Raw Date: Sun, 11 Jan 2015 22:58:39 -0800

Raw message

Hi Tim, I have had no success with this so far. I would like to know if 
there is a way of manually resetting the limit with some code and maybe add 
a button either at the Group or User edit page to reset the limit or even 
add it as a cron job.

The reason I am trying to achieve this is we have a situation where the 
hotspot is installed at an accommodation place where people check out at 
10am and check in at 2pm. We want to have each unit with a static username 
(e.g. Room01) and with a recurring daily limit of say 500mb. The problem is 
that the person checking out at 10am has already used the 500mb for the day 
and then a new person checks in at 2pm and has no internet until after 
midnight!

If this cannot be done any other suggestions would be appreciated.

Thanks for your help!
Derek



On Friday, May 2, 2014 at 8:00:25 PM UTC+10, timwhite88 wrote:
>
>
>
>
> On Fri, May 2, 2014 at 12:59 PM, Derek Mitchell <de***.@gmail.com 
> <javascript:>> 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