Community discussions

MikroTik App
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Moving Simple Queue to Last Position

Thu Feb 18, 2010 9:19 pm

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.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Moving Simple Queue to Last Position

Thu Feb 18, 2010 10:18 pm

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.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 5:30 am

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

that gives you the total number of simple queues.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 5:32 am

also, if you just use "move queuename" without a number it moves it to the end.
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 10:01 am

Thank you very much. I'll test this tonight when I'm back from work.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 10:40 am

> /queue simple print count-only
will return count of simple queues.
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 6:55 pm

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!
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 9:52 pm

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"]
 
changeip
Forum Guru
Forum Guru
Posts: 3830
Joined: Fri May 28, 2004 5:22 pm

Re: Moving Simple Queue to Last Position

Fri Feb 19, 2010 10:11 pm

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"]
 
Pada
Member Candidate
Member Candidate
Topic Author
Posts: 150
Joined: Tue Dec 08, 2009 11:37 pm
Location: South Africa, Stellenbosch

Re: Moving Simple Queue to Last Position

Sat Feb 20, 2010 11:46 am

wow, thanks for that last one changeip. Really appreciate that script.
 
User avatar
chechito
Forum Guru
Forum Guru
Posts: 2990
Joined: Sun Aug 24, 2014 3:14 am
Location: Bogota Colombia
Contact:

Re: Moving Simple Queue to Last Position

Thu Jun 24, 2021 6:13 am

also, if you just use "move queuename" without a number it moves it to the end.
thanks a lot, that worked for me

Who is online

Users browsing this forum: No registered users and 25 guests