Created
August 17, 2021 14:21
-
-
Save zdienos/54f6a6afa5c85f819d6920e56d46635f to your computer and use it in GitHub Desktop.
automatic simple queue for mikrotik hotspot user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOGIN | |
:global MaxLimitDown "4000" | |
:global MaxLimitUp "4000" | |
:local nama $user | |
/queue simple remove [/queue simple find name~"$nama"] | |
:local total [/ip hotspot active print count-only where user=$nama] | |
:if ($total =0) do={ | |
:local LimitDOWN ($MaxLimitDown / $total) | |
:local LimitUP ($MaxLimitUp / $total) | |
/queue simple add name=$address target=$address max-limit=($LimitUP."k/".$LimitDOWN."k") comment=$nama place-before=0; | |
:foreach i in=[/queue simple find comment =$nama] do={/queue simple set $i max-limit=($LimitUP."k/".$LimitDOWN."k")} | |
}\ | |
else={ | |
:local LimitDOWN ($MaxLimitDown / $total) | |
:local LimitUP ($MaxLimitUp / $total) | |
/queue simple add name=$address target=$address max-limit=($LimitUP."k/".$LimitDOWN."k") comment=$nama; | |
:foreach i in=[/queue simple find comment =$nama] do={/queue simple set $i max-limit=($LimitUP."k/".$LimitDOWN."k")} | |
} | |
LOGOUT | |
:local nama $user; | |
/queue simple remove [/queue simple find name =$address] | |
:local total [/ip hotspot active print count-only where user=$nama] | |
:if ($total=0) do={ | |
:log info "All are Devices Logout ??" | |
}\ | |
else={ | |
:local LimitDOWN ($MaxLimitDown / $total) | |
:local LimitUP ($MaxLimitUp / $total) | |
:foreach i in=[/queue simple find comment =$nama] do={/queue simple set $i max-limit=($LimitUP."k/".$LimitDOWN."k")} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment