Please help - auto.rsc problem and import via API problem

Hi!

I’ve been trying all day to figure why this script doesn’t work on MT v3.30 (and v3.23):

:global myVar;
:global lmyVar;
/queue simple 

:set myVar [find limit-at="96k/384k"];
:set lmyVar [:len myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="256k/1024k" max-limit="256k/1024k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="1024k" total-max-limit="1024k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

:set myVar [find limit-at="192k/768k"];
:set lmyVar [:len $myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="512k/2048k" max-limit="512k/2048k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="2048k" total-max-limit="2048k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

:set myVar [find limit-at="384k/1576k"];
:set lmyVar [:len $myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="1024k/4096k" max-limit="1024k/4096k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="4096k" total-max-limit="4096k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

:set myVar [find limit-at="192k/1024k"];
:set lmyVar [:len $myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="512k/3024k" max-limit="512k/3024k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="3024k" total-max-limit="3024k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

:set myVar [find limit-at="384k/1768k"];
:set lmyVar [:len $myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="1024k/5080k" max-limit="1024k/5080k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="5080k" total-max-limit="5080k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

:set myVar [find limit-at="512k/3512k"];
:set lmyVar [:len $myVar];
:if ($lmyVar > 0) do={ :put $myVar; set $myVar limit-at="1536k/8192k" max-limit="1536k/8192k" burst-limit="0/0" burst-threshold="0/0" burst-time="0/0" total-limit-at="8192k" total-max-limit="8192k" total-burst-limit="0" total-burst-threshold="0" total-burst-time="0" ; }

To be more precise, on 3.23 it works sometimes when I do FTP upload with name.auto.rsc, but usually don’t work.

So, to make things easier I’ve figure out to store these files on routers and execute /import name.rsc with API like this:

$talk = array (
	"/import",
	*=name.rsc"
);
$queueResponse 	= mikrotikV3Talk($talk, $mtConnectionHandler);

. At first API reported that everything is OK, router changed queues, but then stalls and lost connection with Winbox (before the stall in Queue window in Winbox I could see old speeds, but in Terminal I could see new speeds). After that it reports

Array
(
    [0] => !done
)

but nothing happens.

In CLI import of name.rsc works like a charm. I’m stunned, I’ve lost all day and need help. Thanks.

Ivan

what language is it? there’s three double quotes… odd number %)

Sorry, later two examples are in PHP, I ment to show how I am calling import from API and what I am getting as response. Main idea is to control all routers from a single server (we have 300+ routers).

Regards,
Ivan

have you tried The Dude?
http://www.mikrotik.com/thedude.php

i would suggest you to check some MUM presentations about that tool.

Thanks, but that is not the issue here. I would like to know why this script won’t autoexecute properly and why API is making issues with it also.

Dude is not the answer for what we need since our network is expanding very quickly and we have custom made information system that needs to be connected with routers. I have earlier made PHP library for executing scripts on v2.9x series RouterOS, and we are now almost 95% switched to v3.3x or v4.x series RouterOS.

Dude is a nice tool, but there is no API for it so we are using it just to monitor router status (up/down), critical wireless signals and some more stuff. Router administration that is common for almost all of our routers must be done by CRON job and we can’t rely on person to do it.

Besides that, Dude has show some problems in terms of stability on our Windows 2008 x64 Server (it doesn’t crash but suddenly stops sending emails or starts sending it non stop, won’t let anyone to log on etc.)

check if you your script is correct, sadly, auto.rsc does not report errors, it just does not execute the script. Maybe some conditions change from one run to another.

AFAIK - there should not be any changes between the runs, either from API, auto.rsc or CLI

check what you have in /system script job print, is it executing properly. Also, how many queues you are changing, that is, how fast script executes.

Ok, let me clarify - script is correct, it executes normaly every time I call it from Terminal. Number of Queues it changes depends, as you can see from the script. Almost all of our routers are either RB433AH or Intel E6300/E7500 based so it really does not matter how many queues has to be changed, but lets say not more than 120 in worst case scenario.

What I am trying to figure out is why it won’t execute when I call it by API even if API responds with

!done

which means that it is executed.

Is there a way to caputre output from API and return it with answer to see if it is executing really or not?

This is major issue for me, since I have aleready stumbled upon some bugs and I need to know what can I expect. I need to develop mass control software for MT routers, and it must work efficiently and without problems. If there are problems I need to have a way to debug them.

Thank you for your interest.

on my test router

/import
=name.rsc

returns:

!trap
=message=unknown parameter
!done

try to run:

/import
=file-name=test.rsc

works every single time i execute it. ROS 4.5