I am currently have Mikrotik setup which I’m trying to remove duplicate login user. Then I found this script over the mikrotik forum. This script works perfectly for user added directly from Mikrotik hotspot, but not working for user added from Usermanager.
Please help to make this working. I cannot find solution anywhere. What I did try is that making group name in usermanager profile limitation to be the same as Hotspot user profile. However, nothing work.
:local uname $user;
:local usercount 0;
:local usertime "00:00:00";
:local kickable;
:local maxuser 2;
:foreach i in=[/ip hotspot active find user=$uname] do= {
:local curup [/ip hotspot active get $i uptime];
:if ( $curup > $usertime ) do={
:set usertime $curup;
:set kickable $i;
}
:set usercount ($usercount+1);
}
:if ($usercount >= $maxuser) do={
:log info "Login user: $uname ($usercount/$maxuser) - Oldest $usertime will be logout!";
/ip hotspot active remove numbers=$kickable;
} else {
:log info "Login user: $uname ($usercount/$maxuser)";
}
I suspect that the problem might be on the 1st line $user where it didn’t detect username from Usermanager.