Hello,
I created a dynamic queue bandwidth sharing/division base on the total number of same users who logged in via Hotspot-> User profiles 's on-Login and On-Logout script.
The script i made is working generally if the ‘On-login’ and ‘On-logout’ events where fired/executed.. however i came into a problem wherein if a certain user disconnects from the Access Point not via the captive portal ( Example. User turn off his/her WiFi on phone or disconnects LAN cable of the computer) the ‘on log out’ script isn’t working. Is this an issue or the On-Logout event is really not firing on other instance of disconnection other than the Log out from the captive portal.
or is there other way to tackle this dynamic queue bandwidth sharing..
here is my sample script:
On-Login
:global DDR "5000";
:global DUR "5000";
:global QID [/queue simple find name="hs-<hotspot>"];
:local UName $user;
/queue simple remove [/queue simple find name~"$UName"];
:local DeviceCount [/ip hotspot active print count-only where user=$UName];
:if ($DeviceCount=0) do={
:local DQPerDevice ($DDR / $DeviceCount);
:local UQPerDevice ($DUR);
:local MaxLimit ($UQPerDevice."K/".$DQPerDevice."K");
/queue simple add name=$address target=$address comment=$UName max-limit=$MaxLimit limit-at=$MaxLimit place-before=$QID;
:foreach QReset in=[/queue simple find comment=$UName] do={/queue simple set $QReset max-limit=$MaxLimit limit-at=$MaxLimit; }
} else={
:local DQPerDevice ($DDR / $DeviceCount);
:local UQPerDevice ($DUR);
:local MaxLimit ($UQPerDevice."K/".$DQPerDevice."K");
/queue simple add name=$address target=$address comment=$UName max-limit=$MaxLimit limit-at=$MaxLimit place-before=$QID;
:foreach QReset in=[/queue simple find comment=$UName] do={/queue simple set $QReset max-limit=$MaxLimit limit-at=$MaxLimit;}
}
On-Log out
:local UName $user;
/queue simple remove [/queue simple find name=$address];
:local DeviceCount [/ip hotspot active print count-only where user=$UName];
:if ($DeviceCount=0) do={
:log info "$UName and it's member is already logged out";
} else {
:local DQPerDevice ($DDR / $DeviceCount);
:local UQPerDevice ($DUR);
:local MaxLimit ($UQPerDevice."K/".$DQPerDevice."K");
:foreach QReset in=[/queue simple find comment=$UName] do={/queue simple set $QReset max-limit=$MaxLimit limit-at=$MaxLimit;}
}