Page 1 of 1

Quota data in hotspot

Posted: Fri Sep 20, 2024 4:51 pm
by Wheelhousemarine
I have a problem with mikrotik hotspot that I still can't solve (I google a lot, there are many people who have the same problem as me and they don't have a solution yet)
I am using mikrotik hotspot to limit user data quota (for example user1 has a total upload and download of 5GB per month). There are 2 authentication methods:
1. Use hotspot-user and set the value for "Limit Bytes Total"; use a script to reset the counter every first day of the month. Users can see the total remaining bytes through the variable $(remain-bytes-total-nice) on the status page.
The problem with this method is: there is no feature to set interim-update for hotspot, so hotspot does not record the number of bytes used by users periodically, it only records when they log out. This causes errors when users do not log out when it comes to the counters reset cycle, or use another wifi, or are out of wifi coverage...
Is there any way to set interim-update for hotspot users?
2. Using user-manager: Create limitations and set value for "Transfer Limit" along with reset counter interval. then create profile limitations, profile, user profile... to apply transfer-limit for users. (interim-update can be set in radius menu)
The problem with this solution is: users, and managers do not know how much remaining capacity of users to have appropriate internet usage plan. There is no variable in status page that can display it. (maybe because of the way radius works, radius server does not pass this parameter to radius clients); when I use user-manager web (http://mikrotik_ip/um), there is also no information about remaining total bytes. I tried reading information in database (sqlite file) but failed.
Is there any way for users, and managers to know this parameter?

Re: Quota data in hotspot

Posted: Fri Sep 20, 2024 11:04 pm
by bpwl
users, and managers do not know how much remaining capacity of users
Yes very limiting with only the "not implemented yet" display.
The counters do get reset as requested. But when the limit is reached the user is denied all access. Giving multiple profiles , or repeatedly the same profile, is the way to have UM jump to the next available profile limitation, when one is consumed.

From time to time the counters get reset with as cause: "System timezone changed. Recalculate timers." I have no idea where this timezone change comes from.
We end up with 'flexible' week-lengths this way. This usage is with wifi login (PEAP/Enterprise)
.
Klembord2.jpg

Re: Quota data in hotspot

Posted: Sat Sep 21, 2024 6:39 am
by Wheelhousemarine
users, and managers do not know how much remaining capacity of users
Yes very limiting with only the "not implemented yet" display.
I try to customize user.js, but inly see obj.user.download to know total download data, nothing to know remain bytes. Do you know how to see sqlite file to know what table this infomation in?

Re: Quota data in hotspot

Posted: Sat Sep 21, 2024 3:08 pm
by bpwl
I use https://sqlitebrowser.org/ as browser to look in that UM database.
But it is for us unknown-structured data (blob's).

I expect it to be in "userprofile". A user can have multiple profiles there, and UM takes the next profile in that list of User-profile if one has reached its limits.
Klembord2.jpg

Re: Quota data in hotspot

Posted: Sat Sep 21, 2024 7:19 pm
by Wheelhousemarine
Thank bpwl,
1. In my option 1 (using hotspot user), have you any idea for synchro real dowload/upload bytes (display in status page) and router (in /ip hotspot user)?
2. monthly reset in UM limitations, is it will reset after 30 days or in 1st monthly?

Re: Quota data in hotspot

Posted: Wed Oct 16, 2024 12:51 am
by bpwl
Well RADIUS (User Manager) accounting data does not get the regular updates from the Hotspot.

Setting attributes like "Acct-Interim-Interval" for the group or user entry in User manager did not help. (Even makes it worse, the eventual interim-update value of the Hotspot server profile, in TAB RADIUS, gets overruled with an empty field.)

Fixed it by changing the Attributes 'Value type' in User Manager from 'uint32' to 'string' for those time settings : 'Acct-Interim-Interval' , 'Idle-Timeout'. They now are correctly set in Hotspot.
'Session-Timeout' to be tested, but I expect the same effect.

Time is written as "00:30:00" , and that's more like a text-string.

Re: Quota data in hotspot

Posted: Wed Oct 16, 2024 10:25 am
by patrikg
On the demo router from Mikrotik the "Time Zone Autodetect" is disable.
You can try setting it manually with your timezone, to get rid of the log message.

Re: Quota data in hotspot

Posted: Wed Oct 16, 2024 11:56 am
by bpwl
Good idea but "Time Zone Autodetect" is disabled. It happens quite frequently this "timezone changed"

Re: Quota data in hotspot

Posted: Wed Oct 16, 2024 12:13 pm
by bpwl
Maybe one day I will understand the difference between "idle timeout" and "keepalive timeout" with Mikrotik.

Both cases below are devices logged in (active) hosts. IP 62 is a Radius user login, IP 63 is a Radius MAC login.
Both are active in Hotspot table.

Radius accounting intermediate updates works now for both.(Session here was too short for the IP:63)
.
Klembord2.jpg
.
.
Too many things are called "timeout" in MT.
Login-timeout is what we know as timeout
Session-timeout is more session allowed time
Keepalive-timeout is expected to send keepalive packets ( https://en.wikipedia.org/wiki/Keepalive )