Community discussions

MikroTik App
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Simple Queues script to change type

Tue Jan 21, 2020 11:28 am

Greetings Miktorik Guru's

Picking up that we have a few of our simple queues that were mistakenly left on defaults or not changed to "wireless default"
Is there a nice and easy way to find and replace?

Wrong entry with bad human input:
add max-limit=10M/10M name="MJane Smith" target=192.168.10.123/32 total-queue=default-small  
(or without any total-queue type)

But it should read:
add max-limit=10M/10M name="John Doe" target=192.168.10.10/32  total-queue=wireless-default 


Any suggestions for a script or command one can run to fix this?
My ideas / plans / efforts were all greeted with errors and I'm sure this is such an easy question for those who can code, its like 20 keystrokes and there is a solution

Thanks!
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7054
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Simple Queues script to change type

Tue Jan 21, 2020 11:30 am

set [find total-queue="default-small" ] total-queue=wireless-default
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Simple Queues script to change type

Tue Jan 21, 2020 12:03 pm

set [find total-queue="default-small" ] total-queue=wireless-default
Thanks for a super fast responce, mrz!
Running from Terminal has not visible result. Neither can I see any changes in the simple queues.
[RTR-name] /queue simple>> set [find total-queue="default-small" ] total-queue=wireless-default
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7054
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Simple Queues script to change type

Tue Jan 21, 2020 2:08 pm

If you have more than one item with total-queue="default-small" then you need to iterate through find results.
For example using foreach
:foreach i in=[find where total-queue="default-small"] do={set $i total-queue=wireless-default }
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Simple Queues script to change type

Tue Jan 21, 2020 7:40 pm

@mrz
You are a total genius with this! Thanks for your assistance.
One last request for some of your knowledge:

Some of the /queue simple lines do NOT have the "total-queue" parameter.
How would one go about to insert that?
I played around with:
:foreach i in=[find where total-queue=""] do={set $i total-queue=wireless-default }
But clearly I'm talking rubbish to my router :-)
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Simple Queues script to change type

Mon Jan 27, 2020 9:37 am

Any of our forum members who can assist with the above "bad" command I'm trying to pump into the router?
 
User avatar
skylark
Member Candidate
Member Candidate
Posts: 144
Joined: Wed Feb 10, 2016 3:55 pm

Re: Simple Queues script to change type  [SOLVED]

Mon Jan 27, 2020 10:29 am

Hey, this should work:
:foreach i in=[/queue simple find where total-queue!="wireless-default"] do={/queue simple set $i total-queue=wireless-default}
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Simple Queues script to change type

Mon Jan 27, 2020 10:46 am

Hey, this should work:
:foreach i in=[/queue simple find where total-queue!="wireless-default"] do={/queue simple set $i total-queue=wireless-default}
@skylark - YOU are amazing my friend. Thank you so much for that command! You have me sorted out now.
 
User avatar
macsrwe
Forum Guru
Forum Guru
Posts: 1007
Joined: Mon Apr 02, 2007 5:43 am
Location: Arizona, USA
Contact:

Re: Simple Queues script to change type

Mon Jan 27, 2020 12:19 pm

Curiously, neither (total-queue="") nor (total-queue is nil) work. One of these really should work.

What does work is:

:foreach i in=[find where ("foo" . total-queue) = "foo"] do={....}

Note that the previous post marked "solution" will simply set every entry to wireless-default, even if it had been deliberately set to something else. If you had wanted to do that, you could have just issued:

set [find] total-queue=wireless-default
 
abjaterza
just joined
Topic Author
Posts: 9
Joined: Sat Jul 09, 2011 2:20 am

Re: Simple Queues script to change type

Mon Jan 27, 2020 1:25 pm

@macsrwe Indeed, my intention was to override whatever the parameters are (or those without any), to "total-queue=wireless-default" ... and then manually change the few who need to be on something else, to whatever is needed for them. Easier to change 10 afterward, than change 200.

Who is online

Users browsing this forum: flyr, NetHorror and 115 guests