sukriborneo

auto-parent-child

Oct 31st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.18 KB | None | 0 0
  1. # pertama, buat on login script untuk profile 1jam, 2jam, 3jam, 1gb dimana saat login akan cek apakah sudah ada parent 1MBPS, bila belum dibuatlah parent 1MBPS tersebut sekaligus membuat childnya :
  2.  
  3. # on login script user profile 1jam-expired-1hari :
  4. {
  5. :local usernya $user;
  6. :local ipnya $address;
  7. :if ([/queue simple find name=1MPBS]="") do={
  8. /queue simple add name=1MBPS target=172.16.16.0/22 max-limit=1M/1M limit-at=1M/1M queue=default/default
  9. /queue simple add name="$usernya$ipnya" parent=1MBPS target=$ipnya max-limit=1M/1M limit-at=1k/1k queue=default/default
  10. } else={
  11. /queue simple add name="$usernya$ipnya" parent=1MBPS target=$ipnya max-limit=1M/1M limit-at=1k/1k queue=default/default
  12. }
  13. :if ([/ip hotspot user find name=$usernya limit-uptime=1h]="") do={/ip hotspot user set [find name=$usernya] limit-uptime=1h};
  14. :if ([/system schedule find name=$usernya]="") do={
  15. /system schedule add name=$usernya interval=1d on-event="/ip hotspot user remove [find name=$usernya]\r\n/ip hotspot active remove [find user=$usernya]\r\n/system schedule remove [find name=$usernya]"
  16. }
  17. }
  18.  
  19. # on logout script user profile 1jam-expired-1hari
  20. {
  21. :local usernya $user;
  22. :local ipnya $address;
  23. /queue simple remove [find name="$usernya$ipnya"];
  24. :if ([/queue simple find parent=1MBPS]="") do={/queue simple remove [find name=1MBPS]}
  25. }
  26.  
  27. ### lakukan hal yang sama untuk time-based 2jam,3jam,harian,mingguan dan bulanan, sesuaikan parent,limit-uptime dan interval ###
  28.  
  29.  
  30.  
  31. # on login script user profile 1gb-expired-1hari :
  32. {
  33. :local usernya $user;
  34. :local ipnya $address;
  35. :if ([/queue simple find name=1MBPS]="") do={
  36. /queue simple add name=1MBPS target=172.16.16.0/22 max-limit=1M/1M limit-at=1M/1M queue=default/default
  37. /queue simple add name="$usernya$ipnya" parent=1MBPS target=$ipnya max-limit=1M/1M limit-at=1k/1k queue=default/default
  38. } else={
  39. /queue simple add name="$usernya$ipnya" parent=1MBPS target=$ipnya max-limit=1M/1M limit-at=1k/1k queue=default/default
  40. }
  41. :if ([/ip hotspot user find name=$usernya limit-bytes-total=1073741824]="") do={/ip hotspot user set [find name=$usernya] limit-bytes-total=1073741824};
  42. :if ([/system schedule find name=$usernya]="") do={
  43. /system schedule add name=$usernya interval=1d on-event="/ip hotspot user remove [find name=$usernya]\r\n/ip hotspot active remove [find user=$usernya]\r\n/system schedule remove [find name=$usernya]"
  44. }
  45. }
  46.  
  47. # on logout script user profile 1gb-expired-1hari
  48. {
  49. :local usernya $user;
  50. :local ipnya $address;
  51. /queue simple remove [find name="$usernya$ipnya"];
  52. :if ([/queue simple find parent=1MBPS]="") do={/queue simple remove [find name=1MBPS]}
  53. }
  54.  
  55. ### lakukan hal yang sama untuk volume-based 10gb dan 100gb, sesuaikan parent,limit-bytes-total dan interval ###
  56.  
  57.  
  58. # system schedule saat mikrotik nyala/startup agar terhapus semua queue simple yang masih tertinggal bila user tidak logout kemudian terjadi pemadaman listrik atau mirkotik reboot atau mirkotik shutdown #
  59. - buat system scheduler , namai delete-queue-user
  60. - start-time = startup
  61. - interval = 0
  62. - on event script :
  63. /queue simple remove [find name=1MBPS]
  64. /queue simple remove [find name=3MBPS]
  65. /queue simple remove [find name=10MBPS]
  66. /queue simple remove [find name=PRIVATE]
Add Comment
Please, Sign In to add comment