Community discussions

MikroTik App
 
flameproof
Member Candidate
Member Candidate
Topic Author
Posts: 128
Joined: Tue Sep 01, 2015 3:17 pm

Stop a running background /tool fetch

Thu Sep 14, 2017 12:43 pm

I have the following setup to do load testing:

- An array of 20 SXTs
- One mANT
- A server behind the mANT

On each SXT there is a script that when run, it starts 10 scheduler tasks which in turn start parallel /tool fetch commands to download (and discard) a 10 MB .zip. This works really nice, but I find that when I remove all the scheduler tasks, there are still many "leftover" fetch commands still running, and bandwidth usage stays high for 1-3 more minutes after the test is stopped.

Is there any way to stop an ongoing background download?
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 282
Joined: Tue Feb 10, 2015 3:21 pm

Re: Stop a running background /tool fetch

Thu Sep 14, 2017 4:39 pm

First of all I would suggest to use tools which are specially designed for traffic testing:

Bandwidth Test:
https://wiki.mikrotik.com/wiki/Manual:T ... width_Test

Traffic Generator:
https://wiki.mikrotik.com/wiki/Manual:P ... _Generator

If you still want to use described method, all script jobs can be terminated with:
/system script job remove [find]

But in case if you want to terminate exactly some specific job which is executed in background, you need to store the script job ID first, and terminate the same ID later.

Quick example how to assign ID to array val, and stop it after specified period of time:
{
    :global arr { "job1"="val1" ; "job2"="val2" }

    ### Set job ID to array val
    :foreach k,v in=$arr do={
        :set ($arr->"$k") [:execute {while (true) do={/tool fetch mode=http url="http://10.5.115.30/BS/1MB.test"}} ]
    }

    :delay 5

    ### Terminate all jobs
    :foreach k,v in=$arr do={
        :put ("Terminate $k=$v")
        /system script job remove $v
    }
}
Other option would be to start multiple scirpts, and remove them by script job name
 
flameproof
Member Candidate
Member Candidate
Topic Author
Posts: 128
Joined: Tue Sep 01, 2015 3:17 pm

Re: Stop a running background /tool fetch

Fri Sep 15, 2017 12:26 pm

Thanks so much for this - we use Bandwidth Test for certain segments of the network, but we want to be able to test traffic under "real" conditions, passing traffic through all Mikrotik boxes in the chain. Other than having a device behind each SXT doing its own traffic (expensive!!) we chose to have the SXT do the download itself.

Who is online

Users browsing this forum: No registered users and 37 guests