Community discussions

MikroTik App
 
prince1990love
newbie
Topic Author
Posts: 32
Joined: Thu Oct 15, 2015 7:19 pm

any body help me pls!!!!!!!!!!!!!!

Mon Feb 29, 2016 4:31 am

any body can help me pls!!! firstly i am sorry for my english :(
i want script in system scheduler for remove all users in hotspot when the limit-bytes-total has reached and over
pls!!!!!!!!
 
prince1990love
newbie
Topic Author
Posts: 32
Joined: Thu Oct 15, 2015 7:19 pm

Re: any body help me pls!!!!!!!!!!!!!!

Mon Feb 29, 2016 4:32 am

no body!!!!!!!
 
User avatar
ShayanFiroozi
Member Candidate
Member Candidate
Posts: 281
Joined: Sat Jun 01, 2013 12:44 pm
Location: Bandar Abbas , Iran

Re: any body help me pls!!!!!!!!!!!!!!

Mon Feb 29, 2016 12:00 pm

Hi , why scripts ??
do it with queue , more reliable , google it , there are many videos on youtube and tiktube
 
User avatar
Splash
Member Candidate
Member Candidate
Posts: 207
Joined: Fri Oct 16, 2015 10:09 am
Location: Johannesburg, South Africa

Re: any body help me pls!!!!!!!!!!!!!!

Mon Feb 29, 2016 2:26 pm

This might help:
# Date:       03/06/2011
# Revised:      22/02/2013
# Revised:      01/08/2013
# Author:       Alfredo Agius
# Revised by Alexander Prozorov - adaptation for RouterOS version 6.xx
# File:         cleanUserManager
# Tested on:    RouterOS version 6.1
#
# Description:    Deletes Mikrotik User-Manager accounts whos not active more or equal 3 month.
#            Accounts which are not yet activated are skipped.
#            Accounts which have valid profile are skipped.
#            A summary of all accounts skipped, deleted and kept is displayed in the end of the cycle to
#            console screen and to log.
#
# Notes:     
#            This script work if NTP package is installed.
#            This script can be run either from WinBox or from console.
#            -- If console is used, all processing details will be shown, and a summary of operations in the end.
#            -- If WinBox is used, all processing details will be HIDDEN, and a summary of operations will be
#               sent to log.
#
# Use:         In Winbox, go to System > Script, create a new script, name it cleanUserManager and paste
#            this whole document in it. Click Apply and OK.
#
# Syntax:      To run the script, from terminal enter "/system script run cleanUserManager" without quotes.

if ([/system ntp client get status]="synchronized") do={
   :global iterator 0
   :global deleted 0
   :global skipped 0
   :global kept 0
   /tool user-manager user print brief  without-paging
   :global counter [/tool user-manager user print count-only]
   :do {
      :local thisDate
      :local thisYear
      :local thisDay
      :local thisMonth
      :local thisSeen
      :local thisProfile
      :local thisOwner
      :local thisCredit
      :local creditYear
      :local creditDay
      :local creditMonth
      :local expireMonth
      :local creditName
      :set thisDate [/system clock get date]
      :set thisYear [:pick $thisDate 7 11]
      :set thisDay [:pick $thisDate 4 6]
      :set thisMonth [:pick $thisDate 0 3]
      :if ($thisMonth="jan") do { :set thisMonth "01"}
      :if ($thisMonth="feb") do { :set thisMonth "02"}
      :if ($thisMonth="mar") do { :set thisMonth "03"}
      :if ($thisMonth="apr") do { :set thisMonth "04"}
      :if ($thisMonth="may") do { :set thisMonth "05"}
      :if ($thisMonth="jun") do { :set thisMonth "06"}
      :if ($thisMonth="jul") do { :set thisMonth "07"}
      :if ($thisMonth="aug") do { :set thisMonth "08"}
      :if ($thisMonth="sep") do { :set thisMonth "09"}
      :if ($thisMonth="oct") do { :set thisMonth "10"}
      :if ($thisMonth="nov") do { :set thisMonth "11"}
      :if ($thisMonth="dec") do { :set thisMonth "12"}
      :local thisSeen [/tool user-manager user get $iterator last-seen]
      :local thisProfile [/tool user-manager user get $iterator actual-profile]
      :local thisOwner [/tool user-manager user get $iterator customer]
      :set creditName [/tool user-manager user get $iterator name]
      :if ([:len $thisProfile]!=0) do {
      :put {"Username ". $creditName . " Have valid profile:". $thisProfile . " Skipping ..."};
      :set skipped ($skipped+1) } else {
      :if ([$thisSeen]!= "never") do {
      :set creditYear [:pick $thisSeen 7 11]
      :set creditDay [:pick $thisSeen 4 6]
      :set creditMonth [:pick $thisSeen 0 3]
      :if ($creditMonth="jan") do { :set creditMonth "02";:set expireMonth "feb"}
      :if ($creditMonth="feb") do { :set creditMonth "03";:set expireMonth "mar"}
      :if ($creditMonth="mar") do { :set creditMonth "04";:set expireMonth "apr"}
      :if ($creditMonth="apr") do { :set creditMonth "05";:set expireMonth "may"}
      :if ($creditMonth="may") do { :set creditMonth "06";:set expireMonth "jun"}
      :if ($creditMonth="jun") do { :set creditMonth "07";:set expireMonth "jul"}
      :if ($creditMonth="jul") do { :set creditMonth "08";:set expireMonth "aug"}
      :if ($creditMonth="aug") do { :set creditMonth "09";:set expireMonth "sep"}
      :if ($creditMonth="sep") do { :set creditMonth "10";:set expireMonth "oct"}
      :if ($creditMonth="oct") do { :set creditMonth "11";:set expireMonth "nov"}
      :if ($creditMonth="nov") do { :set creditMonth "12";:set expireMonth "dec"}
      :if ($creditMonth="dec") do { :set creditMonth "01";:set expireMonth "jan";:set creditYear ($creditYear+1)}
     :set thisCredit ($expireMonth ."/". $creditDay . "/". $creditYear)
      :if ($creditYear>$thisYear) do {
      :put {"Kept username ".$creditName." which expires on ".$thisCredit };
      :set kept ($kept+1) } else {
      :if ($creditYear<$thisYear) do {
      /tool user-manager user remove $creditName;
      :put {"Deleted username ". $creditName . " which expired on " . $thisCredit};
      :set deleted ($deleted+1) } else {
      :if ($creditMonth>$thisMonth) do {
      :put {"Kept username " . $creditName . " which expires on " . $thisCredit};
      :set kept ($kept+1) }  else {
      :if ($creditMonth<($thisMonth)) do {
      /tool user-manager user remove $creditName;
      :put {"Deleted username ". $creditName . " which expired on " . $thisCredit};
      :set deleted ($deleted+1) } else {
       :if ($creditDay>=$thisDay) do {
       :put {"Kept username " . $creditName . " which expires on " . $thisCredit};
       :set kept ($kept +1) }  else {
        /tool user-manager user remove $creditName;
       :put {"Deleted username ". $creditName . " which expired on " . $thisCredit};
       :set deleted ($deleted+1) }
       }
       }
       }
       }
       }  else {
       :put {"Username ". $creditName . " is not yet activated. Skipping ..."};
       :set skipped ($skipped+1)}
       }
       :set iterator ($iterator+1)
       } while=($iterator!=$counter)
   :put {"\r________________________________\n\rCleaning ready!\n\rPerformed these operations:\r\t"}
   :put {"Records processed: \t" . $counter}
   :put {"\rDeleted usernames: \t" . $deleted}
   :put {"Skipped usernames: \t" . $skipped}
   :put {"Kept usernames:\t\t" . $kept}
   :put {"\r__________________________________\r"}

   :log info ("\r_________________________________\n\rCleaning ready!\n\rPerformed these operations:\r\t")
   :log info ("Records processed: \t" . $counter)
   :log info ("\rDeleted usernames: \t" . $deleted)
   :log info ("Skipped usernames: \t" . $skipped)
   :log info ("Kept usernames: \t\t" . $kept)
   :log info ("\r_________________________________\r")

}

#END OF FILE
 
prince1990love
newbie
Topic Author
Posts: 32
Joined: Thu Oct 15, 2015 7:19 pm

Re: any body help me pls!!!!!!!!!!!!!!

Mon Feb 29, 2016 3:56 pm

thanks very much.....that is help :D