124. Mikrotik Hotspot Share User, Share Bandwidth for 2 Devices


You can contact me: plus.google.com/+PhallaCCMT; youtube.com/phallaccmt; facebook.com/Phalla.CCMT; twitter.com/PhallaCCMT and Phalla.CCMT@gmail.com

Login Script:

#Set Default Rate Limit k/s
:local DRateLimit "9000"

#Set User
:local UName "zxc"

#Set User Profile
:loca ProName "Share2_Pro"

#Remove Default Queue
/queue simple remove [/queue simple find name~"$UName"]

:delay 270ms;
#Count Login Device
:local DeviceCount [/ip hotspot active print count-only where user=$UName]

# Set Q Per Device
:local QPerDevice ($DRateLimit / $DeviceCount)

#Set Temporary Device Count
#:local TemDevice ($DeviceCount+1)

#PreRateLimit Per Account
#:local PreRateLimit ($DRateLimit / $TemDevice)

#--------------------if all user logout

:if ($DeviceCount =1) do={

#Add queue
/queue simple add name=$address target=$address max-limit=($QPerDevice."k/".$QPerDevice."k") comment=$user place-before=0;

#Edit Q
:foreach QEdit in=[/queue simple find comment =$UName] do={/queue simple set $QEdit max-limit=($QPerDevice."k/".$QPerDevice."k")} 

#/ip hotspot user profile set [/ip hotspot user profile find name =$ProName] rate-limit= ($DRateLimit."k/".$DRateLimit."k");

}\

else={

#Add queue
/queue simple add name=$address target=$address max-limit=($QPerDevice."k/".$QPerDevice."k") comment=$user place-before=0;

#Edit Q
:foreach QEdit in=[/queue simple find comment =$UName] do={/queue simple set $QEdit max-limit=($QPerDevice."k/".$QPerDevice."k")} 

#/ip hotspot user profile set [/ip hotspot user profile find name =$ProName] rate-limit= ($PreRateLimit."k/".$PreRateLimit."k")

}



Logout Script:

#Set Default Rate Limit k/s
:local DRateLimit "9000"

#Set User
:local UName "zxc"

#Set User Profile
:loca ProName "Share2_Pro"

:delay 270ms;
#Count Device Login
:local DeviceCount [/ip hotspot active print count-only where user=$UName]

#--------------------if all user logout

:if ($DeviceCount =1) do={

#Remove Q
/queue simple remove [/queue simple find name =$address]

#Reset Queue
:local ResetQ ($DRateLimit / $DeviceCount)

#Edit Q
:foreach EditQ in=[/queue simple find comment =$UName] do={/queue simple set $EditQ max-limit=($ResetQ."k/".$ResetQ."k")} 

}\

else={

#Remove Q
/queue simple remove [/queue simple find name =$address]

#Reset Queue
:local ResetQ ($DRateLimit / $DeviceCount)

#Edit Q
:foreach EditQ in=[/queue simple find comment =$UName] do={/queue simple set $EditQ max-limit=($ResetQ."k/".$ResetQ."k")} 

}


Previous
Next Post »