Community discussions

MikroTik App
 
samartsupply
just joined
Topic Author
Posts: 5
Joined: Sat Nov 19, 2016 5:07 pm

How to script delele user expire in usermanager

Thu Apr 27, 2017 7:16 pm

How to script delele user expire in usermanager in version 6.38
I cann't find total-time-left in script delete
 
User avatar
ahmedalmi
Frequent Visitor
Frequent Visitor
Posts: 75
Joined: Sat Sep 13, 2014 5:52 pm
Location: sana'a yemen
Contact:

Re: How to script delele user expire in usermanager

Sat Apr 29, 2017 10:23 pm

if you want to delete users expir valdate use this script
/tool user-managaer users remove [find !actual-porofile];

if you want to delete expire uptime limit
/tool user-man user remove [find actual-profile=porfilename and uptime-used=10h];
change your profile name instead of "profilename" and uptime limit for this profile instead of "10h"

if you want to delete expire transfer limit
use this script for one profile then next profile - just change word profilename in first line and 100000000 (100Mb) in 5 line by your transfer for same profile

:foreach i in=[/tool user-man user find where download-used>0 and actual-profile=profilename ] do={
:local name [/tool user-man user get $i username];
:local upload [/tool user-man user get $i upload-used];
:local download [/tool user-man user get $i download-used];
:local limitdown 100000000;
:local updown ($upload + $download);
:if ( $updown >= $limitdown ) do={
/tool user-man user remove $i;
}
}
 
alfntoosh
just joined
Posts: 6
Joined: Wed May 21, 2014 2:59 am
Location: Yemen
Contact:

Re: How to script delele user expire in usermanager

Thu Mar 15, 2018 9:05 am

it's working on 6.40v :
/tool user-manager user remove [find where !actual-profile ];
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Mon Mar 19, 2018 6:34 am

Hello how are you!
The question is: how should I implement the script?
Do I have to do it in SYSTEM> SCRIPTS?
What I need is that the users of the USER MANAGER who consumed their total time or who have time to consume but who are not connected for a period of 1 hour are eliminated.
I thought of an alternative to the script looking at midnight, which users had a minimum of "download" traffic (or a lot of traffic), so I know that voucher was used.
I want the rb to do it every day at 00:00 (to erase the users that were used during that day).

I hope you can help me please.
Thanks for your time.
Greetings.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Mon Mar 19, 2018 8:26 pm

use this with profile scripts
#Remove expired users 
{ 
:foreach ExpireUser in=[/tool user-manager user find where !actual-profile] do={ 
     /tool user-manager user remove $ExpireUser; 
	} 
} 
You do not have the required permissions to view the files attached to this post.
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Tue Mar 20, 2018 7:16 pm

use this with profile scripts
#Remove expired users 
{ 
:foreach ExpireUser in=[/tool user-manager user find where !actual-profile] do={ 
     /tool user-manager user remove $ExpireUser; 
	} 
} 
*******************
Hi Adahi, first of all, I appreciate your time.
I tested the scipt, and it worked fine but only with the first user:
I did this:
In the user manager:
+ delete all used users, create 2 new ones.
+ first test voucher consumed its time (2 minutes), after a few minutes the voucher self-eliminated.
But with the following used vouchers the script did not go any further.

Questions and doubts :
1) why does the script have to go in the "user profile> script" section, and not for example in ip> scheuduler? (doubt)
2) why does the same script have to go in the "log in" and in "log out"?
doing this, the sript would run when a new user logs in?
3) in the notebook, does not automatically redirect me to the login when connecting to the hotspot signal (I still have the original login of the mikrotik), how could this be solved? (on cell phones / tablets (works automatically).

Thank you very much.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Tue Mar 20, 2018 7:42 pm

use this with profile scripts
#Remove expired users 
{ 
:foreach ExpireUser in=[/tool user-manager user find where !actual-profile] do={ 
     /tool user-manager user remove $ExpireUser; 
	} 
} 
*******************
Hi Adahi, first of all, I appreciate your time.
I tested the scipt, and it worked fine but only with the first user:
I did this:
In the user manager:
+ delete all used users, create 2 new ones.
+ first test voucher consumed its time (2 minutes), after a few minutes the voucher self-eliminated.
But with the following used vouchers the script did not go any further.

Questions and doubts :
1) why does the script have to go in the "user profile> script" section, and not for example in ip> scheduler? (doubt)
2) why does the same script have to go in the "log in" and in "log out"?
doing this, the sript would run when a new user logs in?
3) in the notebook, does not automatically redirect me to the login when connecting to the hotspot signal (I still have the original login of the mikrotik), how could this be solved? (on cell phones / tablets (works automatically).

Thank you very much.
you welcome
the script will work in parallel with every log in or log out of any user
1) instead of [/system scheduler], no need for script to work in interval time.
2) you can chose on of them or both, for example in logout only ,when any user logout, the script will check for expired users then if exist->remove it
3) theirs is no relation between script and log in page, if you have any issues you can do [/ip hotspot reset-html [find]] to reset login page to default.
you welcome
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Tue Mar 20, 2018 7:52 pm

Adahi ,:

How often does the user "expire"?
case a) the voucher was consumed in its entirety its time.
case b) the voucher only consumed some of its time.

in both cases, would the script work?

And because it could be, that now, when a user enters or disconnects a user, it does not erase the vouchers already occupied?

it seems to me that the problem comes, that I only try with one device, after a few minutes I try another voucher and the device works normally, but it does not erase the voucher already used.

What do you recommend that I check or change to make it work?

Ideally, when entering a new user with a new voucher, for example, delete the used vouchers

PD1:
I add image of log mk, the voucher "33iak", it is deleted automatically after the user is disconnected from the network ..
I will not have a problem with some cokiee or something like that?

the rest of the tests I did did not work anymore the script

Image


If you need any capture of my current configuration, ask me.
PD 2: I also did this test.
I upload the script to run it manually, and it does not delete the vouches already used.
pd3:
we must bear in mind that being a place where the voucher system is going to be implemented, there are users who will occupy the entire voucher (total time) and there are some users who will occupy a few minutes and then they are removed from the place, in both cases, once the voucher is started, when the user is disconnected for any of the two reasons, either that the system cuts off access due to a time limit or because the user leaves the place; eliminate the voucher
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Tue Mar 20, 2018 10:51 pm

script only remove expired users
expire-user = (user/pass without active profile)
profile expire depend on period of time (ex: 1d) or quota (100MB) or both
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Wed Mar 21, 2018 1:37 am

Adahi, the issue of user expired, either time or mb quota, I have to configure it in the "profile" of the USER MANAGER, is this correct? or do I have to do it in ip> hotspot?

thanks again.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Thu Mar 22, 2018 12:26 am

Adahi, the issue of user expired, either time or mb quota, I have to configure it in the "profile" of the USER MANAGER, is this correct? or do I have to do it in ip> hotspot?

thanks again.
yes user manager
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Thu Mar 22, 2018 6:37 pm

Hello, Adahi.
After many tests with devices and users, the script you gave me is perfect as long as the voucher has been fully occupied, that is, the user manager disconnects the user at the end of time or end of quote (mb).
Now the only thing I have left to solve, are the users who open a voucher but leave before their time / quote, could you help me with that case? thank you very much.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Thu Mar 22, 2018 10:54 pm

Now the only thing I have left to solve, are the users who open a voucher but leave before their time / quote, could you help me with that case? thank you very much.

how do you know user left before their time / quote ?
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Sat Mar 24, 2018 3:17 am

I have many cases, (being a bar to drink coffee and the traffic is totally touristy), few tourists stay 1 hour for example, they are a while and they retire, that is why I am going to have to find some solution to the vouchers initiated but not finished.
Simple test, I disconnect the test devices, and the session in the "session" part in the user manager, does not expire, the user appears as inactive, but it does not expire.
This happens a lot because this scenario is not sale, if it is logical that all users will consume their total time / quota, but in this case they will not.
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: How to script delele user expire in usermanager

Sat Mar 24, 2018 9:25 pm

did you specify validity of profile?
You do not have the required permissions to view the files attached to this post.
 
pabloluvino
just joined
Posts: 11
Joined: Mon Jan 08, 2018 10:54 pm

Re: How to script delele user expire in usermanager

Wed Mar 28, 2018 2:26 am

Good afternoon, Adahi.
Yes, it is configured as you show me the example.
Attached photos of current configuration, and as an example, a capture of Saturday March 24, probe with a device, turn off the Wi-Fi device and until now I mark the session, never expired.
Image

Image

Image

Image


thank you, and if I have to correct something, just tell me.
 
User avatar
erwindrew
just joined
Posts: 3
Joined: Fri Nov 24, 2017 9:45 am

Re: How to script delele user expire in usermanager

Thu Apr 19, 2018 9:35 am

use this with profile scripts
#Remove expired users 
{ 
:foreach ExpireUser in=[/tool user-manager user find where !actual-profile] do={ 
     /tool user-manager user remove $ExpireUser; 
	} 
} 
nice. it works. thanks.
 
ramzanali
just joined
Posts: 1
Joined: Wed Dec 26, 2018 3:11 pm

Re: How to script delele user expire in usermanager

Thu Jan 03, 2019 1:51 pm

Hi ,
I have configured one profile with 4w2d time limit in user manager. I have many users (250) in user manager.I want after one month time the expired user should be delete from the user list.what is the script for this and where to put it?

please guide me in proper way as i dnt have much knowledge with mikrotik.'


Thanks
 
Edwardpum
just joined
Posts: 2
Joined: Fri Mar 15, 2019 11:36 am
Location: Zimbabwe
Contact:

How to script delele user expire in usermanager

Mon Mar 25, 2019 1:15 am

can anyone guide me as to how to make user specific rules....i mean i know how to make global rules but not specifically to a single user?

Regards

Who is online

Users browsing this forum: No registered users and 6 guests