Hi everybody,
I thanks AYcoo posted the code below. It worked well.
However, I would like test tx-rate+rx rate of active users. If tx-rate+rx rate >10m, this user will put slow profile.
What code can I do that?
Please help me! Thanks a lot for any guide.
Thanks, Thanks, Thanks…
nz_monkey:
i think i got it now but if anyone can improve this will be great
all will be running in schedule first
:foreach i in=[/ip hotspot active find] do={
/ip hotspot active remove $i
}
/ip hotspot user {
:local limitedProfile "4m"
:local limitedSlowProfile "LimitedSlow4"
:local trafLimit 7516192768
:local userList [find profile=$limitedProfile]
:foreach user in=$userList do={
:local traf ([get $user bytes-in] + [get $user bytes-out])
:put ("User (" . [get $user name] . ") traf: " . $traf)
:if ($traf > $trafLimit) do={
set $user profile=$limitedSlowProfile
:put ("User (" . [get $user name] . ") reached the traf limit")
:log warning ("User (" . [get $user name] . ") reached the traf limit")
}
}
}
/ip hotspot user {
:local limitedProfile "6m"
:local limitedSlowProfile "LimitedSlow6"
:local trafLimit 7516192768
:local userList [find profile=$limitedProfile]
:foreach user in=$userList do={
:local traf ([get $user bytes-in] + [get $user bytes-out])
:put ("User (" . [get $user name] . ") traf: " . $traf)
:if ($traf > $trafLimit) do={
set $user profile=$limitedSlowProfile
:put ("User (" . [get $user name] . ") reached the traf limit")
:log warning ("User (" . [get $user name] . ") reached the traf limit")
}
}
}
/ip hotspot user {
:local limitedProfile "2m"
:local limitedSlowProfile "LimitedSlow2"
:local trafLimit 7516192768
:local userList [find profile=$limitedProfile]
:foreach user in=$userList do={
:local traf ([get $user bytes-in] + [get $user bytes-out])
:put ("User (" . [get $user name] . ") traf: " . $traf)
:if ($traf > $trafLimit) do={
set $user profile=$limitedSlowProfile
:put ("User (" . [get $user name] . ") reached the traf limit")
:log warning ("User (" . [get $user name] . ") reached the traf limit")
}
}
}
run this every day three times for example at 3:00 pm 12:00 pm , 10:00 as you like above code will kick users the will change speed of thous who reached limit to limitslow
second
then use another script to reset counters and their original speed (Daily ) at midnight for example
{
:local limitedProfile "4m"
:local limitedSlowProfile "LimitedSlow4"
/ip hotspot user reset-counters [find (profile=$limitedProfile || profile=$limitedSlowProfile)]
/ip hotspot user set [find profile=$limitedSlowProfile] profile=$limitedProfile
:log warning "All user limits has been reset"
}
change profiles and do one for every profile you have
i wanna thank Deantwo for helping me out
if you have some improvement for this please share and thanks