Community discussions

MikroTik App
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Script to change pcq rates on certain time

Fri Apr 19, 2019 3:33 am

I'm trying to build a script to DOUBLE some pcq rates on a certain hour of the day.
this is what I tried
/queue type set [find where pcq-rate!=0] pcq-rate=([/get [find where name~"MYPCQ"] value-name=pcq-rate]*2)

/queue type set [find where pcq-rate!=0] pcq-rate=([get [find where kind=pcq] value-name=pcq-rate]*2)

i'm getting this error everytime
invalid internal item number
Please advise on how to do it.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to change pcq rates on certain time

Fri Apr 19, 2019 9:50 am

You can create two script and schedule them as start and stop like this

Lower pcq-rate
/queue type set pcq-rate=50 [/queue type find where name=MYPCQ]
Increase pcq-rate
/queue type set pcq-rate=100 [/queue type find where name=MYPCQ]
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: Script to change pcq rates on certain time

Fri Apr 19, 2019 11:59 am

There is a large number of pcq types and everyone has a different value, i need something to multiply the current value of ALL pcq-rates and multiply it by 2.
Please advise.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to change pcq rates on certain time

Fri Apr 19, 2019 10:40 pm

This should do:
:foreach i in=[/queue type find where name~"MYPCQ"] do={
/queue type set pcq-rate=([/queue type get number=$i pcq-rate]*2) numbers=$i }
It will double all pcq-rate for all queues that do contains the text MYPCQ

You can use the same to divide it by later /2
Last edited by Jotne on Fri Apr 19, 2019 10:51 pm, edited 1 time in total.
 
User avatar
pnajm
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 94
Joined: Thu Nov 21, 2013 6:54 pm

Re: Script to change pcq rates on certain time

Fri Apr 19, 2019 10:45 pm

Awesome! I will try it out.
Thank you so much!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Script to change pcq rates on certain time

Fri Apr 19, 2019 10:52 pm

You are welcome :)
Did an update of the post above to shorten it more.

Example test for all Queues with letter D
[admin@test-router] > /queue type export
 # apr/19/2019 21:33:29 by RouterOS 6.44.2
# software id = xxxx
#
#
#
/queue type
add kind=pcq name=Demo pcq-rate=400
add kind=pcq name=Data pcq-rate=100
[admin@test-router] > [
[... :foreach i in=[/queue type find where name~"D"] do={
[{... /queue type set pcq-rate=([/queue type get number=$i pcq-rate]*2) numbers=$i }
[... ]
[admin@test-router] > /queue type export
# apr/19/2019 21:33:40 by RouterOS 6.44.2
# software id = xxxx
#
#
#
/queue type
add kind=pcq name=Demo pcq-rate=800
add kind=pcq name=Data pcq-rate=200

Who is online

Users browsing this forum: rextended and 26 guests