Community discussions

MikroTik App
 
User avatar
ljb
just joined
Topic Author
Posts: 16
Joined: Mon Feb 28, 2022 9:39 pm

Set simple queue entry if condition is met.

Sat Sep 17, 2022 5:11 am

My mind is going round and round in circles because it does not seem to honour the condition "max-limit not equal to 1024k/1024k.

 :if ([/queue simple find name=queue10] max-limit!=1024k/1024k) do={ /queue simple set [find name="queue10"] max-limit=1024k/1024k } else= { :put "no action" } 

For the sake of sanitising the log feed, I am attempting to only action when current settings does not match the new.

Where am I going wrong?

LJB
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Set simple queue entry if condition is met.  [SOLVED]

Sat Sep 17, 2022 9:30 am

You where close:
{
/queue simple 
:if ([find where name=queue10 max-limit!="1024k/1024k"]) do={
	set [find name="queue10"] max-limit="1024k/1024k"
} else={
	:put "no action"
}
}
First { and last } are not needed in script. Just to get working in copy past terminal.
Also better to use multiple lines instead of one long line with all in one go.
You can also make a foreach loop to go through many queues to change all.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Set simple queue entry if condition is met.

Sat Sep 17, 2022 10:20 am

Sorry, but no... Do not be influenced on what the user write...

(this version do not give errors if queue10 do not exist or is removed later)
/queue simple set [find where name="queue10" and max-limit!="1024k/1024k"] max-limit="1024k/1024k"
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Set simple queue entry if condition is met.

Sat Sep 17, 2022 11:06 am

Shortening it down as always :)
 
User avatar
ljb
just joined
Topic Author
Posts: 16
Joined: Mon Feb 28, 2022 9:39 pm

Re: Set simple queue entry if condition is met.

Sat Sep 17, 2022 3:52 pm

Jotne, rextended - the names I see time and time again in forum posts - thank you for your swift response.

It appears that the omission of the "where" word was my failure for predictable results. A word I see all too often in sql.

Sometimes it takes a little bump like this to get back on track.

Who is online

Users browsing this forum: own3r1138 and 25 guests