Reaching out to anyone who has experience in customised hotspot scripting. Free advice is always welcome, however we are willing to book some paid time with any consultants who specialise in this area if they know how to resolve our issues.
The story so far:
We are finding that devices are being marked as overquota when in fact they are not overquota or they haven't been used at all. Additionally, I believe the script that is supposed to clear all user sessions daily is not removing the overquota users and therefore the following day they are still being reported as overquota.
The first script hotspot-user-clear is scheduled for 5am daily and is intended to clear all user sessions so the same devices can log in with a new data allowance every 24 hours:
Code: Select all
:foreach counter in=[/ip hotspot user find ] do={/ip hotspot user remove $counter}
Code: Select all
#Download limit in MB
:local downquotamb 1000
### Do not modify anything below this line ###
:local downquota ($downquotamb * 1000 * 1000)
:local counter
:local datadown
:local username
:local macaddress
:foreach counter in=[/ip hotspot active find ] do={
:set datadown [/ip hotspot active get $counter bytes-out]
:if ($datadown>$downquota) do={
:set username [/ip hotspot active get $counter user]
:set macaddress [/ip hotspot active get $counter mac-address]
/ip hotspot user remove [/ip hotspot user find where name=$username]
:if ( $username="T-$macaddress") do={
/ip hotspot user add name=$username limit-bytes-out=$downquota mac-address=$macaddress
/ip hotspot active remove $counter
}
:log info "Logged out $username - Reached download quota"
}}
Code: Select all
Usage report start
=====
Live users:
User: T-4C:B1:99:2C:70:FB - 14/43 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-64:BC:0C:9D:FC:C6 - 10/146 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-5C:F5:DA:E2:DD:3F - 7/170 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-80:E6:50:4B:49:2C - 84/9 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-04:46:65:5A:D0:10 - 1/8 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-90:B9:31:84:FE:4C - 148/929 (MB UP/DOWN) / (Limit MB UP/Down)
=====
Overquota Users: User: default-trial - 13545/57333 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-AC:29:3A:26:A6:C7 - 137/956 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-64:76:BA:A6:FE:64 - 34/989 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-80:EA:96:B7:FB:8B - 65/968 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-04:0C:CE:E3:35:4C - 13/954 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-6C:40:08:B8:35:6E - 41/1018 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-04:15:52:92:2F:13 - 32/1034 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-68:9C:70:20:1F:CC - 30/1011 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-A4:C3:61:26:33:AF - 33/987 (MB UP/DOWN) /953 (Limit MB UP/Down)
User: T-70:3E:AC:2B:E2:B2 - 13/215 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-90:B9:31:D2:6E:19 - 1/12 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-04:46:65:5A:D0:10 - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-90:B9:31:84:FE:4C - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-80:E6:50:4B:49:2C - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-5C:F5:DA:E2:DD:3F - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-4C:B1:99:2C:70:FB - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
User: T-64:BC:0C:9D:FC:C6 - 0/0 (MB UP/DOWN) / (Limit MB UP/Down)
=====
End of message
![Image](http://sammond.com/Screen%20Shot%202016-03-10%20at%2011.51.55%20AM.jpg)