Dynamic Queue change script

Hi, Please check my scripts. Where I`m missing? I want to increase x2 rate limit of dynamics queues every day at 22:00.

:foreach i in=[/queue simple find] do={
:local speed [/queue simple get [/queue simple find name=$i] limit-at];
:queue simple set [/queue simple find name=$i] limit-at="$speed*2";
}

:local speed [/queue simple get 0 limit-at]
:foreach i in=[/queue simple find] do={
:queue simple set [/queue simple find name=$i] limit-at=“$speed*2”
}

try this to do.:slight_smile:

maybe limit-at not a num,so…can’t to cal。maybe need to pick this vale。

Hi 9939781,
Thank you for answer. But each value of queue limit rates are different. I have about 500 PPPoE active users. I think I have 2 problem.

  1. I think my script “foreach i” is not correct
  2. Value of limit-at is not only digits. It will be for example “1M/1M”. So I need to get only digit before unit.

:global leng ([:len [/queue simple get 0 limit-at]] / 2)
:global speedrx [:pick [/queue simple get 0 limit-at] 0 ($leng - 1)]
:global bt [:pick [/queue simple get 0 limit-at] ($leng - 1) $leng]
:global newspeedrx (speedrx * 2)
:global speedtx [:pick [/queue simple get 0 limit-at] 0 ($leng - 1)]
:global bt [:pick [/queue simple get 0 limit-at] ($leng +1) 0]
:global newspeedtx (speedtx * 2)
:global newspeed ($newspeedrx . $bt . “/” . $newspeedtx . $bt)
:put $newspeed
:foreach i in=[/queue simple find] do={
/queue simple set $i limit-at=$newspeed max-limit=$newspeed
}

i think this can working.i write and test is ok.

Hey 9939781, Thank you very much for your great idea.

I have done my scripts. I have tested it in small network few times, works great. I will test it tonight in target network. There is about 500 dynamic rules. Hope it will work without any trouble.

 [otgonkhuu@MOBINET] > system scheduler print detail
2   name="SpeedBooster-ON" start-date=jun/22/2011 start-time=22:00:00 interval=1d on-event=
/queue simple; :foreach i in=[find] \ 
do={:local speed [(([:pick [get $i limit-at] 0 [(([:len [get $i limit-at]]/2)-1)]])*2000)];
/queue simple set $i limit-at="$speed/$speed" max-limit="$speed/$speed"}  

3   name="SpeedBooster-OFF" start-date=jun/23/2011 start-time=08:00:00 interval=1d on-event=
/queue simple; :foreach i in=[find] \ 
do={:local speed [((([:pick [get $i limit-at] 0 [(([:len [get $i limit-at]]/2)-1)]])*1000)/2)];
/queue simple set $i limit-at="$speed/$speed" max-limit="$speed/$speed"}

Also now I need to do next actions:

  1. To add scheduler that stops Radius connection during my scripts finish to change all queues. Because does not need any new connection at the time, when script us running.
  2. To add query in FreeRadius server, that changes all customer speed information at the time, when RouterOS script starts.
  3. I have some Total queues in the /queue simple, that do not need to change limit rates. It means, need to exclude some simple queue rules from variable
:foreach i

Sorry my bad english :slight_smile:

btw, you cannot change settings for dynamic objects, only remove them in RouterOS. If you change settings for customer, then speed limitation will work only when customer reconnects.

I have tested successfully. When customer is downloading 1024kbps, I have changed dynamic simple queue to 512kbps. Customer download limit has decreased immediately to 512Kbps. My ROS is V5.2 and my tested hardware is RB433UAH, RB1000 and PowerRouter2282 (x86). Please janisk help me, how can I exclude some queue rules from variable :foreach i?

you could add internal if check, to see comment or something, if item has to be skipped or not. Other change is to find queues with different find parameters and then run foreach i on the search results.

:global rez [queue simple find where comment=“do not pass”]

foreach i in rez …

yes. That is good idea. Thank you janisk. I will do this.

Please see below topic and give me your great advices. Thanks.
http://forum.mikrotik.com/t/script-based-on-logs/48049/1

Hi otgooneo

I need information about our script to change dynamic queues. Can`t you help mi ?

Hi cobiszon. Sure. I`ll help you if I can. How to help you?

Hi
In my network I have PPPoE tunels and all data are takes from Radius server and MySQL databese. I try to put night tariff about boost speed twice on RO.

So, I tried run your script on RO v5.6

/queue simple; :foreach i in=[find] \
do={:local speed [(([:pick [get $i limit-at] 0 [(([:len [get $i limit-at]]/2)-1)]])*2000)];
/queue simple set $i limit-at="$speed/$speed" max-limit="$speed/$speed"}

in effect I recive message from system about error:

Script Error: cannot multiply string by time interval

I do not know where error is, perhaps I copied incorrectly or any other problem.
Any idea whats wrong I do ?

It works on V5.0rc11 and 5.15. I guess your rate limit format is not in format kbps. Copy paste below script on your console screen.

/queue simple; :foreach i in=[find] \
do={:put [:pick [get $i limit-at] 0 [(([:len [get $i limit-at]]/2)-1)]];

What is the result?

Hi

I run this code whith small modification since You missed a curly brackets at end of script:

/queue simple; :foreach i in=[find] \
do={:put [:pick [get $i limit-at] 0 [(([:len [get $i limit-at]]/2)-1)]]};

In result I recive list of client queues in table RX

If I run next part of sctipt:

/queue simple set $i limit-at="$speed/$speed" max-limit="$speed/$speed";

result is:

syntax error (line 1 column 20

I would search error in last code

  1. “syntax error (line 1 column 20)” is correct, because you need to use local variable $i inside of {}. It will be ok.
  2. Please post your result. How it look like?