Community discussions

MikroTik App
 
Philippe57
just joined
Topic Author
Posts: 10
Joined: Fri Feb 09, 2024 4:22 pm

hotspot usernam: deletion of user beyond the deadline

Wed Feb 28, 2024 7:30 pm

Hello everyone

I'm looking for a script that I would run every day at midnight, to delete users exceeding 7 days since the first connection as well as the associated sessions.

I have 3 privileges:
1 week
3 days
3 hours

I would like to repeat the script for each profile

so I'm looking to make a comparison between the date or time of the first connection (1 week, 3 days, 3 hours) and delete the user concerned as well as their session



Thank you for your help
 
eldoncito2019
Member
Member
Posts: 333
Joined: Fri Jun 14, 2019 1:07 pm

Re: hotspot usernam: deletion of user beyond the deadline

Thu Feb 29, 2024 8:16 pm

Greetings, I have had this script running for some time friend, paste it as it is in each of the "User Profiles" that you have.
:local comment "IN USE"
:local userprofile [ip hotspot user get [find where name="$user"] profile]

:if ([/ip hotspot user get $user comment]="") do={[/ip hotspot user set $user comment=$comment]}

[/system scheduler 
add comment= [/ip hotspot user profile get [find where name="$userprofile"] name] name=$user on-event="/ip hotspot user remove \"$user\" \r\
  \n/system scheduler remove [find where name=\"$user\"] \r\
  \n\r\
" interval= [/ip hotspot user profile get [find where name="$userprofile"] session-timeout]]
I hope it is useful to you.
 
Philippe57
just joined
Topic Author
Posts: 10
Joined: Fri Feb 09, 2024 4:22 pm

Re: hotspot usernam: deletion of user beyond the deadline

Fri Mar 01, 2024 10:26 am

hello and thank you for the feedback

but I use useman, I don't think the user is deleted at the same time on it

here is my configuration of my userman:


# mar/01/2024 08:20:30 by RouterOS 6.49.13
# software id = 
#
#
#
/tool user-manager profile
add name=User-1-Semaine name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name="user 60s" name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name=User-3-jours name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
add name=User-3-heures name-for-users="" override-shared-users=10 owner=admin price=0 starts-at=logon validity=0s
/tool user-manager profile limitation
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=60s owner=admin transfer-limit=0B upload-limit=0B uptime-limit=1m
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-3-jours owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
    rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=3d
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-3-heures owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
    rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=3h
add address-list="" download-limit=0B group-name="" ip-pool="" ip-pool6="" name=Hotspot-1-semaine owner=admin rate-limit-min-rx=10485760B rate-limit-min-tx=10485760B rate-limit-rx=10485760B \
    rate-limit-tx=10485760B transfer-limit=0B upload-limit=0B uptime-limit=1w
/tool user-manager database
set db-path=user-manager
/tool user-manager profile profile-limitation
add from-time=0s limitation=60s profile="user 60s" till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-3-heures profile=User-3-heures till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-1-semaine profile=User-1-Semaine till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
add from-time=0s limitation=Hotspot-3-jours profile=User-3-jours till-time=23h59m59s weekdays=sunday,monday,tuesday,wednesday,thursday,friday,saturday
 
Philippe57
just joined
Topic Author
Posts: 10
Joined: Fri Feb 09, 2024 4:22 pm

Re: hotspot usernam: deletion of user beyond the deadline

Mon Mar 04, 2024 6:05 pm

OK, I made progress on my code.

now I have a problem adding dates:

my viriable: $lastSeenStr which has the format for example: mar/04/2024 15:53:20 and my other variable: $validity which has the value for example: 3d00:00:00

I can't add the dates

do you have an idea ?


THANKS

Who is online

Users browsing this forum: No registered users and 9 guests