Community discussions

MikroTik App
 
pkelly1603
Member Candidate
Member Candidate
Topic Author
Posts: 105
Joined: Mon Jun 15, 2009 11:13 pm

Script Error - "system is busy (12)"

Tue Jul 22, 2014 4:26 pm

Hi,

I am running 6 scripts, each running on its own schedule. I noticed many times they are not running on schedule. When I manually run one of these for a test, I get this error:
 system is busy (12) 
This does not happen every time the script is run. Is scripting only able to run one thread at a time? Any ideas?

My scripts are monitoring latency and packet loss then recording by logging error if they cross certain thresholds. The first 3 scripts are running flood-ping of 1 packet to different IP addresses every 10 seconds (I call these "probe" scripts). The other 3 analyze the statistics gathered by the first 3 every 4 minutes (I call these "analyze" scripts).
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:12 pm

Have you notice that you do not provide ANY detail?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:25 pm

You give me -1 as "Stupid response"?


My reply:

-1: Question without any detail about routerboard model, routeros version used and without any export of problematic scripts.

Do you think "we" are magicians guessing things without seeing them or try them?
 
pkelly1603
Member Candidate
Member Candidate
Topic Author
Posts: 105
Joined: Mon Jun 15, 2009 11:13 pm

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:35 pm

Have you notice that you do not provide ANY detail?
Not sure what details you are talking about as I provided the basic information that I believed necessary. Here's some more information though:

- running routerOS 5.26
- Same issue occurs on x86 RouterOS VM and RB450
- Problem only arises when scripts run very frequently (multiple scripts with 10 second interval)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:38 pm

Wait some minutes, I test flood ping on RB450G (I do not have not G model) and routeros 5.26.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:41 pm

SOLVED:

YOU CAN HAVE ONLY ONE ACTIVE FLOOD-PNG SESSION

No matter if you open one or more winbox / ssh /telnet.


The system (also on 6.17) can do only one flood-ping at the same time.

If you try to launch multiple flood, system is busy (12) occour.

system is busy (12) = function already used on another session

You can see "system is busy (12)" only on CLI (console / telnet / SSH) , because on winbox simply not work, and on script on default do not leave any log.
 
pkelly1603
Member Candidate
Member Candidate
Topic Author
Posts: 105
Joined: Mon Jun 15, 2009 11:13 pm

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:46 pm

Here is the "probe" script:
# Variables - ipsla1
:global ipsla1;
:local name ipsla1;
:local response  -1;
:local target 8.8.8.8;
:local pingSize 1200;

#Variables derived from stored settings
:local currentIndex
:local livesKept
:local currentStat

#Ping target and gather latest statistic
/tool flood-ping $target count=1 size=$pingSize do=\
{
    :set response $"avg-rtt";
};

#Get stored Index
:set currentIndex [/ip proxy access get [find comment="Current Index - $name"] dst-port]; 
:set currentStat [/ip proxy access find (method="$name" and dst-host="$currentIndex")];
:set livesKept [/ip proxy access get [find comment="Current Index - $name"] dst-host]; 

#Check if no response
:if ($response = 0) do=\
{
    /ip proxy access set $currentStat dst-port=9999 dst-address=$target;
} \
else=\
{
    /ip proxy access set $currentStat dst-port=$response dst-address=$target;
};

#Increment index to next (set back to start if at end)
:if ($currentIndex>=$livesKept) do=\
{
    :set currentIndex 1;
} else=\
{
    :set currentIndex ($currentIndex+1);
};

/ip proxy access set [/ip proxy access find comment="Current Index - $name"] dst-port=$currentIndex
Here is the "analyze" script:

#User set variables
#Variable for storing up/down status of ipsla (if this variable is edited, make sure to edit checks at the end of this script)
:global ipsla1
##Name (must match the name used in createStorageVariables script
:local ipslaName ipsla1;
#Number of previous statistics to calculate loss/latency averages on
:local checkNumStats 100;
#Threshold for when latency will cause monitor to be down status
:local latencyThreshold 500;
#Threshold for when packet loss will cause monitor to be down status (this variable is a percentage)
:local lossThreshold 15;

#Variables derived from stored settings
:local livesKept [/ip proxy access get [find comment="Current Index - $ipslaName"] dst-host]; 
:local currentStatLatency;
:local currentIndex [/ip proxy access get [find comment="Current Index - $ipslaName"] dst-port];
#Decrease current index by one since current index is pending update but currentindex-1 is the most recently updated
:if ($currentIndex=1) do=\
{ 
    :set currentIndex ($livesKept); 
} else=\
{ 
    :set currentIndex ($currentIndex-1); 
};
:local startIndex $currentIndex;
:local totalLatency 0;
:local avgLatency;
:local percentLoss;
:local received 0;
:local lost 0;
:local polledIp;

#Go through loop as many times as necessary to gather each statistic that will be calucalted upon
:for i from=1 to=($checkNumStats) do=\
{
#### Store latency of current statistic
    :set currentStatLatency [/ip proxy access get [find (method="$ipslaName" and dst-host="$currentIndex")] dst-port]; 
#### Check if value is flagged with 9999 (ping timed out)
    :if ($currentStatLatency=9999) do={:set lost ($lost+1);} else=\
    {
######## If not timed out, add latency to total
#        :put $currentStatLatency
        :set received ($received+1);
        :set totalLatency ($totalLatency+$currentStatLatency);
    };
####Check if index is at the end of the statistic list, reset to beginning if necessary
    :if ($currentIndex=1) do=\
    { 
        :set currentIndex ($livesKept); 
    } else=\
    { 
        :set currentIndex ($currentIndex-1); 
    };
};
:set polledIp [/ip proxy access get [find (method="$ipslaName" and dst-host="$currentIndex")] dst-address];
:set percentLoss (($lost*100) / (($received+$lost)));
:if ($received=0) do=\
{
    :set avgLatency 0;
} else=\
{
    :set avgLatency ($totalLatency/$received);
};

#Log statistics
:log info "Ran $ipslaName analyze script, checked last $checkNumStats poll(s) on $polledIp"
:log info "Average Latency: $avgLatency";
:log info "Percent loss: $percentLoss (lost: $lost, Received $received)";

#Add whatever checks on latency and percent loss down here along with actions
:if (($percentLoss>$lossThreshold) || ($avgLatency>$latencyThreshold)) do=\
{
    :if (($ipsla1)!="down") do=\
    {
        :set ipsla1 "down"
        :log error ("$ipslaName is down"); 
        :log error ("Packet Loss: $percentLoss  Average Latency: $avgLatency");
    };
} else=\
{
    :if (($ipsla1)="down") do=\
    {
        :log error ("$ipslaName is back up");
    };
    :set ipsla1 "up";
 };
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:47 pm

is possible to use on script:

:do { "/tool flood-ping etc." } on-error={ /log warning message="Flood Ping Busy" };

If you must continue the running of the script...

Or set one global variable at startup:

:global floodpingbusy value=false;

And set/unset is as true when one script use that function, and add check to other script to wait until is usable, etc...
 
pkelly1603
Member Candidate
Member Candidate
Topic Author
Posts: 105
Joined: Mon Jun 15, 2009 11:13 pm

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:50 pm

is possible to use on script:

:do { "/tool flood-ping etc." } on-error={ /log warning message="Flood Ping Busy" };

If you must continue the running of the script...

Or set one global variable at startup:

:global floodpingbusy value=false;

And set/unset is as true when one script use that function, and add check to other script to wait until is usable, etc...
OK, thanks for the suggestions.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:52 pm

On one script run at startup:
:global floodpingisbusy value=false;
and change ALL YOUR SCRIPTS ON SAME ROUTERBOARD WHERE FLOOD PING IS USED with:
:while ( $floodpingisbusy ) do={ /delay delay-time=1 };
:set $floodpingisbusy value=true;

/tool flood-ping $target count=1 size=$pingSize do={
:set $response value=$"avg-rtt";
};
:set $floodpingisbusy value=false
Is not indented for highlighting new parts.


EDIT: added ALL YOUR SCRIPTS ON SAME ROUTERBOARD WHERE FLOOD PING IS USED
Last edited by rextended on Tue Jul 22, 2014 9:59 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 9:57 pm

Please let me know if solved.

Thanks.
 
pkelly1603
Member Candidate
Member Candidate
Topic Author
Posts: 105
Joined: Mon Jun 15, 2009 11:13 pm

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 11:05 pm

Thank you, it is working as expected.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12445
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Script Error - "system is busy (12)"

Tue Jul 22, 2014 11:08 pm

Thank you, it is working as expected.
Next time think twice before give -1...

Who is online

Users browsing this forum: No registered users and 12 guests