Community discussions

MikroTik App
 
AAw
just joined
Topic Author
Posts: 5
Joined: Tue Sep 02, 2014 5:16 pm

False Active Sessions!

Sat Jan 14, 2023 2:55 pm

Hi there!
I have a problem with user manager which is in an external CHR with v6.49.6
I always find false active sessions in user manager while they are not active anymore.
I have tried some scripts but they not work.
I need a script that close (not remove if possible) these active sessions.
anyone have the right script please?
2023-01-14_153659.png
You do not have the required permissions to view the files attached to this post.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: False Active Sessions!

Sat Jan 14, 2023 5:57 pm

since only you know what are "false" or not, use your hand.
 
AAw
just joined
Topic Author
Posts: 5
Joined: Tue Sep 02, 2014 5:16 pm

Re: False Active Sessions!

Sat Jan 14, 2023 9:53 pm

What the whole preceding post was quoted for? Is it a problem to just use "Post Reply" button?
I'm doing it by hand now. but the script with scheduler will do it for me with ease! :D
Last edited by BartoszP on Thu Jan 19, 2023 9:40 am, edited 1 time in total.
Reason: removed excessive quotting of preceding post; be wise, quote smart, save network traffic
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: False Active Sessions!  [SOLVED]

Sat Jan 14, 2023 11:49 pm

:global datetime2epoch do={
    :local dtime [:tostr $1]
    /system clock
    :local cyear [get date] ; :if ($cyear ~ "....-..-..") do={:set cyear [:pick $cyear 0 4]} else={:set cyear [:pick $cyear 7 11]}
    :if (([:len $dtime] = 10) or ([:len $dtime] = 11)) do={:set dtime "$dtime 00:00:00"}
    :if ([:len $dtime] = 15) do={:set dtime "$[:pick $dtime 0 6]/$cyear $[:pick $dtime 7 15]"}
    :if ([:len $dtime] = 14) do={:set dtime "$cyear-$[:pick $dtime 0 5] $[:pick $dtime 6 14]"}
    :if ([:len $dtime] =  8) do={:set dtime "$[get date] $dtime"}
    :if ([:tostr $1] = "") do={:set dtime ("$[get date] $[get time]")}
    :local vdate [:pick $dtime 0 [:find $dtime " " -1]]
    :local vtime [:pick $dtime ([:find $dtime " " -1] + 1) [:len $dtime]]
    :local vgmt  [get gmt-offset]; :if ($vgmt > 0x7FFFFFFF) do={:set vgmt ($vgmt - 0x100000000)}
    :if ($vgmt < 0) do={:set vgmt ($vgmt * -1)}
    :local arrm  [:toarray "0,0,31,59,90,120,151,181,212,243,273,304,334"]
    :local vdoff [:toarray "0,4,5,7,8,10"]
    :local MM    [:pick $vdate ($vdoff->2) ($vdoff->3)]
    :local M     [:tonum $MM]
    :if ($vdate ~ ".../../....") do={
        :set vdoff [:toarray "7,11,1,3,4,6"]
        :set M     ([:find "xxanebarprayunulugepctovecANEBARPRAYUNULUGEPCTOVEC" [:pick $vdate ($vdoff->2) ($vdoff->3)] -1] / 2)
        :if ($M>12) do={:set M ($M - 12)}
    }
    :local yyyy  [:pick $vdate ($vdoff->0) ($vdoff->1)] ; :if ((($yyyy - 1968) % 4) = 0) do={:set ($arrm->1) -1; :set ($arrm->2) 30}
    :local totd  ((($yyyy - 1970) * 365) + (($yyyy - 1968) / 4) + ($arrm->$M) + ([:pick $vdate ($vdoff->4) ($vdoff->5)] - 1))
    :return      (((((($totd * 24) + [:pick $vtime 0 2]) * 60) + [:pick $vtime 3 5]) * 60) + [:pick $vtime 6 8] - $vgmt)
}

{
    :local NOW [$datetime2epoch]
    /tool user-manager session
    :foreach sessioneTest in=[find where active=yes] do={
        :local tilltime  [$datetime2epoch [get $sessioneTest till-time]]
        :local diff      ($NOW - $tilltime)
        :local threshold 120
        :if ($diff > $threshold) do={
            :log warning "Session closed: $[get $sessioneTest user] has been stalled for $diff seconds"
            close-session $sessioneTest
        }
    }
}
Last edited by rextended on Fri May 19, 2023 3:17 pm, edited 10 times in total.
 
AAw
just joined
Topic Author
Posts: 5
Joined: Tue Sep 02, 2014 5:16 pm

Re: False Active Sessions!

Thu Jan 19, 2023 12:16 am

What the whole preceding post was quoted for? Is it a problem to just use "Post Reply" button?
Thank you very much, it worked very well.
I really appreciate your help.
Last edited by BartoszP on Thu Jan 19, 2023 9:40 am, edited 1 time in total.
Reason: removed excessive quotting of preceding post; be wise, quote smart, save network traffic
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: False Active Sessions!

Thu Jan 19, 2023 12:04 pm

Thanks also to you, for the reply!
 
kosarkarami726
just joined
Posts: 1
Joined: Wed Aug 02, 2023 8:43 pm

Re: False Active Sessions!

Fri Aug 04, 2023 11:36 am

I have the problem too.
But my server and user manager are on two separate routers. What changes should I make in this scrpit and how should I run it?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: False Active Sessions!

Fri Aug 04, 2023 3:04 pm

I have the problem too.
But my server and user manager are on two separate routers. What changes should I make in this scrpit and how should I run it?
The script work only where the user-manager is.

For run automatically the script, must be used the scheduler.
For be used manually, just paste it on terminal.

Is for RouterOS v6, not for RouterOS v7. On v7 user-manager not exist anymore, is just another shitty program called again user-manager.
 
kosarkarami726
just joined
Posts: 1
Joined: Wed Aug 02, 2023 8:43 pm

Re: False Active Sessions!

Mon Aug 07, 2023 11:08 pm

I have the problem too.
But my server and user manager are on two separate routers. What changes should I make in this scrpit and how should I run it?
The script work only where the user-manager is.

For run automatically the script, must be used the scheduler.
For be used manually, just paste it on terminal.

Is for RouterOS v6, not for RouterOS v7. On v7 user-manager not exist anymore, is just another shitty program called again user-manager.
thanks a lot.
yes you are right. shifty program!
we ran in to lots of problems with it.
I will run the script in a while and inform here.
 
User avatar
bpwl
Forum Guru
Forum Guru
Posts: 2993
Joined: Mon Apr 08, 2019 1:16 am

Re: False Active Sessions!

Wed Apr 10, 2024 12:49 am

With the V5 User Manager (ROS 7) and ROS6 routers there is a similar problem, with EAP wifi authentication
User Manager closes the session, as it detects the router (NAS) is not responding at a certain point in time.
User manager closes the session, but the NAS (AP) does not.
Then accounting packets are sent at the set interval but ignored as the session does not exist in User Manager.

User Manager sends a request (port 3799) to close that session on the NAS (AP)
But gets back a NAK for this closure request. ("empty SSID" as potential reason?)
And then User Manager keeps repeating this all the time.
Ending with many many sessions with accounting failure in the router profile incrmenting, and closure reason "NAS rebooted"

Workaround so far, is disable EAP accounting in the security profile in the AP, what will close all the sessions in the NAS (AP), and tell User Manager.
Security profile in the wireless setup, it's not in the RADIUS setting.
You do not have the required permissions to view the files attached to this post.
 
User avatar
bpwl
Forum Guru
Forum Guru
Posts: 2993
Joined: Mon Apr 08, 2019 1:16 am

Re: False Active Sessions!

Wed Apr 10, 2024 12:59 am

Accounting packets keep coming
As User Manager claims the NAS (router/AP) rebooted, but the NAS did not reboot. The wifi sessions are still active.

..

Klembord-3.jpg
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: netmas and 20 guests