i want script for auto delete users after reaching traffic limit in hotspot!
and that is my code
:foreach i in [/ip hotspot user find profile=default] do={
:if ([/ip hotspot user get $i limit-bytes-total]<=[/ip hotspot user get $i
limit-bytes-total]) do={
/ip hotspot user remove $i
}
}
but it’s not work
what is wrong ???
your script logic is flawed…
:if ([/ip hotspot user get $i limit-bytes-total]<=[/ip hotspot user get $i limit-bytes-total]) do={
/ip hotspot user remove $i
}
it basically says if X <= X then remove… it might as well say “if 1 = 1 then remove” or - just “remove”
You’re pulling the same field from the same user (held in $i) twice, and comparing them…
you need to do something more like this:
/ip hotspot user
:local bytestotal = [ :get $i bytes-in ] + [ :get $i bytes-out ]
:if ( $bytestotal > [ :get $i limit-bytes-total ] ) do={
/ip hotspot user remove $i
}
My syntax for the addition between the two gets might be wrong, but the logic is what’s important. You need to get the current used bytes and compare that with the limit-bytes-total value, which is just a limit set by the account’s properties and never changes.
thank you ZeroByte for reply but is not work
any idead
please give me a complete script if possible zeroByte
any body can help me pls!!!