#1

 Note: Currently using JuanFi WiFi Vendo system. For Reference visit JuanFi by Ivan Alayan


big thanks credits to mr.aljhon tronics



1.  add a script to the end of On-Logout in user profile

User Profile On Logout


Content Unlocked:

Code:
/sys sch set [find where name=$user] comment="";





2.)  copy and paste to terminal to create scheduler

Mikrotik Terminal

Content Unlocked:

Code:
/system scheduler
add interval=5s name="uptime backup" on-event=":local hsactiveuptime;\r\
    \n:local hsuser;\r\
    \n:local hslimit;\r\
    \n\r\
    \n:if ([/ip hotspot active print count-only] > 0) do={\r\
    \n:foreach i in=[/ip hotspot active find] do={\r\
    \n:set hsactiveuptime [/ip hotspot active get \$i uptime];\r\
    \n:set hsuser [/ip hotspot active get \$i user];\r\
    \n:set hslimit [/ip hotspot user get \$hsuser limit-uptime];\r\
    \n/system scheduler set [find where name=\$hsuser] comment=\"temp \$hsacti\
    veuptime\";\r\
    \n\t\t}\r\
    \n\t}\r\
    \n" policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    start-time=startup
add name="uptime restore" on-event=":local ucom;\r\
    \n:local hsolduptime;\r\
    \n:local hsnewuptime;\r\
    \n:local hsactiveuptime;\r\
    \n:local hsuser;\r\
    \n:local temp; \r\
    \n:foreach ie in=[/sys sch find] do={\r\
    \n :set \$ucom [/sys sch get \$ie comment]; \r\
    \n:if (\$ucom != \"\") do={ \r\
    \n:set \$temp [:pick \$ucom 0 4];\r\
    \n:if (\$temp = \"temp\") do={\r\
    \n  :set \$hsuser [/sys sch get \$ie name]; \r\
    \n:if ([/ip hotspot user find name=\$hsuser]) do={\r\
    \n:set \$hsolduptime [/ip hotspot user get [find where name=\$hsuser] limi\
    t-uptime];\r\

    \n:set \$hsactiveuptime [:pick \$ucom 5 ([:len \$ucom] + 1)]; \r\
    \n:set \$hsnewuptime (hsolduptime - \$hsactiveuptime);\r\
    \n/ip hotspot user set [find where name=\$hsuser] limit-uptime=\$hsnewupti\
    me;\r\

    \n/sys sch set [find where name=\$hsuser] comment=\"\";} else={ /sys sch r\
    emove \$ie;}\r\
    \n}}}" policy=\
    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
    start-time=startup




As you read the script the uptime backup will get the active users uptime and it will comment the current active uptime
of user to the user scheduler for every 5 seconds. By adding the OnLogout script it will remove the user scheduler
comment because it will automatically saved to uptime statistics of user. The issue on sudden Power Interruption with
fix by uptime restore and it will run after 3 seconds of Mikrotik bootup.

--Forum Rules --BBcodes


image quote pre code