Moving Simple Queue to Last Position

Hi,

I’m looking for a script, that can move 1 of my Simple Queues to the last position, that I can schedule to run at regular intervals (or more specifically: whenever a new PPTP VPN client connects).

My current situation is that I’m using the User Manager, where I’ve set a rate limit to each client. Whenever one of these clients connects, their rate limit is done by simply appending a new Simple Queue.
I’ve also created a Simple Queue (PCQ type) to limit all the PPTP VPN users in total, however, this Simple Queue moves up in the Queue Order whenever a new client connects.

I’ve tried to write a script for this, but I was unable to move the Simple (PCQ) Queue to the last position. I was only able to move it to the 2nd-last position, if I knew the number of simple queues, which I can’t get/find with a script.
Currently my best approach would be to try and move it to position 2, then to 3, then to 4, etc., ensuring that it would be in the 2nd-last position.

Help would be appreciated.

Instead of moving your queue behind everything, move everything else in front of it. Make sure you can uniquely identify the queue and it should work as below:

[admin@MikroTik] /queue simple> pri where name~"^test"
Flags: X - disabled, I - invalid, D - dynamic
 2    name="test" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

 3    name="test2" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

 4    name="test3" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small
[admin@MikroTik] /queue simple> move [find name!="test"] [find name="test"]
[admin@MikroTik] /queue simple> pri where name~"^test"
Flags: X - disabled, I - invalid, D - dynamic
 3    name="test2" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

 4    name="test3" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

 2    name="test" dst-address=0.0.0.0/0 interface=all parent=none direction=both priority=8 queue=default-small/default-small limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s total-queue=default-small

Edit: original post had pretty inefficient solution with a foreach loop.

:put [:len [/queue simple find] ]

that gives you the total number of simple queues.

also, if you just use “move queuename” without a number it moves it to the end.

Thank you very much. I’ll test this tonight when I’m back from work.

/queue simple print count-only
will return count of simple queues.

print count-only has worked in the past on other nodes, but sometimes it’s removed. I’ve stuck with :len because its always worked : ) Thanks MT, your software rocks!

Thank you everyone.

fewi, your script was the simplest and it worked straight away:

/queue simple
move [find name="PCQ-Limit VPN Total"] [find name!="PCQ-Limit VPN Total"]

Try this, it should be more efficient as it only moves 1 queue instead of all of them:

/queue simple
move [find name=“PCQ-Limit VPN Total”]

wow, thanks for that last one changeip. Really appreciate that script.

thanks a lot, that worked for me