Queue Script.

Hello i have managed to get all my scripts i need working by looking at other scripts and looking at the wiki, however this one i cant seem to do. I have tried examples of other scripts and they dont work. So i am wondering if i have my queue setup correctly for this script.

What i want to be able to do is this. Customers are allowed 500MB per day so when the queue download figure hits 500715200 the download speed will be changed from 512 to 256.

Also we do not have a clean list of ip address`s over the network i.e 1 - 254, its more like 10 20 21 23 24 25 29 type thing and i understand there is a problem if there is a break in the ip for some of the scripts i have tried.

Take a look:

Here is a config example of my queue for a customer:

name=“Kevin” target-addresses=192.168.0.189/32 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=256000/512000
burst-limit=/512000 burst-threshold=/128000 burst-time=/35s
total-queue=default-small

This is the script i run to check the queues and to change the speed:

:local traf 0;
/queue simple
:foreach i in=[find dynamic=yes] do={
:set traf [get $i total-bytes]
:if ($traf > 500715200) do = {
set $i max-limit= 256000/256000
}
}

The script runs but dont do anything, please can some point me to what i have done wrong,

Thanks

Darren

Hello rednetwifi:
1st of all,there is really some ill in Ur solution.I think that you can change you key to mark your customers.U can mark the customers by MAC.I think it’s better.
2nd,you can creat 2 queues for one Mac(customer).One has a high bandwidth.And it can count the hits.Teh other one has a low bandwidth that you want to config to.And it can make your customers have a low speed,whos hits is more than 500M.Then you do make sure the 2nd queue is disabled.
3rd,Creat a script to find the total hits of every Mac.And the 2nd queue rule will be enabled by the script,when the mac’s hits up over 500M.

I will have a test for you in my network. Then I’ll give you a solution later.

Yours Hillzen
Mail: hillzen@163.com

If total-queue=default-small then queue will not count total-bytes.
change total-queue to default.

Hey Thanks, I need this answer!!! :smiley:

hello, when the user logout and re-login the counters are reset so it will count him the 500mb again what’s the solution so this will work daily not each time he logins in an out?

You have to add static interface or use radius server for accounting.

Well, it really should be a simple as this:

:local traf 0;
/queue simple
:foreach i in=[find] do={
  :if ([get $i dynamic] = yes && [get $i total-bytes] > 500715200) do={
    set $i max-limit= 256000/256000
  }
}

I can’t count the many many times I’ve had problems getting find to search between different versions.
When find is used by itself it returns all data, which can be parsed. This should work across any version of RouterOS.