Console error, Call for Help for Tool Developping Issue

RouterOS v.6.33rc37 03/11/2015

Up and Download Rate Calculator + Queue-Simple Generator v1.0

To use with the New Terminal

Para usar com o New Terminal Console do Mikrotik

Para os Brasileiros

Não use esta Calculadora abaixo de 300 kb/ps

{

Select here to switch the auto queue-simple Generator on/off

Selecione aqui para usar ou não o auto gerador de queues-simples on/off

:global selector "on";

set your desired queue simple Name here

coloque o Nome da queue simple aqui

:global name "test1";

Address and Mask setup here

Configurar Endereço é Mascara aqui

:local ip "192.168.0.0"; # <- set Target Address for simple queue here ( coloque aqui o Endereço do Alvo da queue-simple ) #
:local msk "24"; # <- set mask here, for single address /32 ( coloque a mascara de rede aqui, se for endereço unico coloque /32 ) #

set your Contract Download Bandwidth here, only Numbers, do not use less than 300 kb/ps, required format is kb/ps

coloque a Veloçidade de Download do Contrato Cliente aqui, escreve em kb/ps, não use menos de 300 kb/ps, vai da error

:local cdb "30000";

set how much Percent from Download your Upload will be

coloque aqui quantos % baseado no Download ceria o Upload

:local up "40";

set how much Percent more than Contracted Bandwidth your Client can reach, 1% -> 100% Recomendet is max of 50%

the Burst Value, maximal upload/download data rate which can be reached while the burst is allowed

coloque aqui o bico maximo em %, a Velocidade a qual o Cliente chegara por algums segundos

:local burst "50";

set the Value burst-threshold in Percent less than Contracted Bandwidh, Recommended is 10% -> 50%

burst-threshold - this is value of burst on/off switch

coloque aqui a média do bico da Velocidade, Recomendado e de 10 a 50%

:local thre "10";

set the Value burst-time here, allowed 1-60 seconds, Recomended 10 seconds

coloque aqui o tempo em segundos do bico, Recomendado 10 segundos

:local time "10";

set the Priority here allowed Value 1-8, Recomended Value= 8, smaller Value causes more Cpu Usage

coloque aqui a Prioridade, Valores entre 1 é 8, Valor Recomendado= 8, Cuidado se da Prioridade de mais vai dar muito CPU Consumo, Numero maiór menos Prioridade

:local prt "8";

set how much Percent is your guaranted Bandwidth, Recomended is 25% - 80%, get Information from your ISP

coloque aqui a Velocidade minima qual Você pode garantir com certeza

:local guaranty "50";

DO NOT CHANGE ANY VALUES BELOW

:local ca [($cdb / 100)];
:local cb [($ca*$up)];
:local cc [($cdb / 100)];
:local cd [($cc*$burst)];
:local ce [($cd+$cdb)];
:local cf [($cb / 100)];
:local cg [($cf*$burst)];
:local ch [($cg+$cb)];
:local ci [($cf*$thre)];
:local cj [($cb-$ci)];
:local ck [($cc*$thre)];
:local cl [($cdb-$ck)];
:local cm [($cb / 100)];
:local cn [($cm*$guaranty)];
:local co [($ca*$guaranty)];
:put ("Calculated Rate Limit is -> " . "$cb" . "k" . "/" . "$cdb" . "k" . " " . "$ch"
. "k" . "/" . "$ce" . "k" . " " . "$cj" . "k" . "/" . "$cl" . "k" . " " . "$time" . "/" . "$time" . " " . "$prt"
. " " . "$cn" . "/" . "$co");
:put ("Your Contract calculated Upload" . " / " . "Upload do Contrato Calculado -> $cb kb/ps");
:put ("Your Contract Download" . " / " . "Download do Contrato -> $cdb kb/ps");
:put ("Burst-Limit Upload" . " / " . "Bico Maximo do Upload -> $ch kb/ps");
:put ("Burst-Limit Download" . " / " . "Bico Maximo do Download -> $ce kb/ps");
:put ("Burst-Threshold-Upload" . " / " . "Media do Bico do Upload -> $cj kb/ps");
:put ("Burst-Threshold-Download" . " / " . "Media do Bico do Download -> $cl kb/ps");
:put ("Burst-Time in Seconds" . " / " . "Tempo do Bico em Segundos -> $time");
:put ("Your minimal guaranted Upload Speed" . " / " . "Garantia do Upload no minimo -> $cn kb/ps");
:put ("Your minimal guaranted Download Speed" . " / " . "Garantia do Download no minimo $co kb/ps");
:if ($selector = "on") do={
:put ("QUEUE AUTO GENERATOR IS ON");
:put ("O QUEUE GERADOR ESTA ATIVADO");
:if ([/queue simple find comment="$name" ] = "$name" ) do={
:local eng "CHECK YOUR SIMPLES QUEUES!! ALREADY EXIST QUEUE SIMPLES WITH SUCH NAME -> $name ";
:local ptbr "VEREFICE SEUS SIMPLES QUEUES !! JA TEM UMA COM ESTE MESMO NOME -> $name ";
:put ("$eng");
:put ("$ptbr");} else={
/queue simple
add burst-limit=("$ch" . "k" . "/" . "$ce" . "k") burst-threshold=("$cj" . "k" . "/" . "$cl" . "k") burst-time=("$time" . "s" . "/" . "$time" . "s")
comment="$name" limit-at=("$cn" . "k" . "/" . "$co" . "k") max-limit=("$cb" . "k" . "/" . "$cdb" . "k") name="$name" target=("$ip" . "/" . "$msk")
:put ("Gerando queue-simple com o Nome -> $name, Endereco do Alvo $ip, Mascara de Rede " . "/" . "$msk");
:put ("Generating queue-simple with Name -> $name, Target address $ip, Network Mask " . "/" . "$msk");
}
} else={
:put ("THE QUEUE AUTO GENERATOR IS SWITCHED OFF, IF YOU WISH TO USE TURN -> ON <- ABOVE");
:put ("O QUEUE GERADOR ESTA DESATIVADO, PARA ATIVAR SELECIONE -> ON <- LA EM CIMA");}
}

:confused:

When I insert this script two times with the same Name console Display error
failure: already have such name
this part from my script doesn't work
:if ([/queue simple find comment="$name" ] = "$name" ) do={
The question is Why ????????????????????

/queue simple print
;;; test1
name="test1" target=192.168.0.0/24 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=6M/15M max-limit=12M/30M burst-limit=18M/45M burst-threshold=10800k/27M burst-time=10s/10s

Comes this Problem bacause the wrong Position of the brackets ?????????????

Look this simple example below!

{
:global ip "192.168.0.2";
:global newname "test1";
:foreach i in=[queue simple find where dynamic=no ] do={
:local name [/queue simple get $i name ];
:if ("$name" != "$newname") do={
/queue simple add name="$newname" target=("$ip" . "/" ."32") comment="$newname"
} else={
:local error "already exists";
:put ("$newname $error");
}
}
}

/queue simple print
0 D name="hotspot-10:D3:74:8A:05:7A" target=10.63.241.214/32 parent=none packet-marks="" priority=8/8
queue=hotspot-default/hotspot-default limit-at=20k/40k max-limit=40k/80k burst-limit=50k/100k
burst-threshold=30k/68k burst-time=8s/8s

1 ;;; JC
name="JC" target=172.16.0.2/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=32k/64k max-limit=64k/128k burst-limit=100k/150k burst-threshold=60k/120k burst-time=10s/10s

2 D name="hs-" target=bridge parent=none packet-marks="" priority=8/8 queue=hotspot-default/hotspot-default
limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

3 ;;; test
name="test" target=192.168.0.1/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s
now add script

New Terminal display

/command Use command at the base level
[ersitizastes@Server] > {
{... :global ip "192.168.0.2";
{... :global newname "test1";
{... :foreach i in=[queue simple find where dynamic=no ] do={
{{... :local name [/queue simple get $i name ];
{{... :if ("$name" != "$newname") do={
{{{... /queue simple add name="$newname" target=("$ip" . "/" ."32") comment="$newname" } else={
{{{... :local error "already exists";
{{{... :put ("$newname $error");
{{{... }
{{... }
{... }
failure: already have such name

/queue simple print

Flags: X - disabled, I - invalid, D - dynamic
0 D name="hotspot-10:D3:74:8A:05:7A" target=10.63.241.214/32 parent=none packet-marks="" priority=8/8
queue=hotspot-default/hotspot-default limit-at=20k/40k max-limit=40k/80k burst-limit=50k/100k
burst-threshold=30k/68k burst-time=8s/8s

1 ;;; JC
name="JC" target=172.16.0.2/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=32k/64k max-limit=64k/128k burst-limit=100k/150k burst-threshold=60k/120k burst-time=10s/10s

2 D name="hs-" target=bridge parent=none packet-marks="" priority=8/8 queue=hotspot-default/hotspot-default
limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

3 ;;; test
name="test" target=192.168.0.1/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

4 ;;; test1
name="test1" target=192.168.0.2/32 parent=none packet-marks="" priority=8/8 queue=default-small/default-small
limit-at=0/0 max-limit=0/0 burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s

Why ?????????????????

Now Insert the Script with the same newname

/command Use command at the base level
[ersitizastes@Server] > {
{... :global ip "192.168.0.2";
{... :global newname "test1";
{... :foreach i in=[queue simple find where dynamic=no ] do={
{{... :local name [/queue simple get $i name ];
{{... :if ("$name" != "$newname") do={
{{{... /queue simple add name="$newname" target=("$ip" . "/" ."32") comment="$newname" } else={
{{{... :local error "already exists";
{{{... :put ("$newname $error");
{{{... }
{{... }
{... }
failure: already have such name

next pass is remove the ! in :if ..........

{
:global ip "192.168.0.2";
:global newname "test1";
:foreach i in=[queue simple find where dynamic=no ] do={
:local name [/queue simple get $i name ];
:if ("$name" = "$newname") do={
/queue simple add name="$newname" target=("$ip" . "/" ."32") comment="$newname"
} else={
:local error "already exists";
:put ("$newname $error");
}
}
}

[ersitizastes@Server] > {
{... :global ip "192.168.0.2";
{... :global newname "test1";
{... :foreach i in=[queue simple find where dynamic=no ] do={
{{... :local name [/queue simple get $i name ];
{{... :if ("$name" = "$newname") do={
{{{... /queue simple add name="$newname" target=("$ip" . "/" ."32") comment="$newname" } else={
{{{... :local error "already exists";
{{{... :put ("$newname $error");
{{{... }
{{... }
{... }
test1 already exists
test1 already exists
failure: already have such name
[ersitizastes@Server] >

NOTHING YET FROM ANYONE ???
THERE ARE NO GEAT MIKROTIK PROGRAMMERS TO REPAIR YHIS SCRIPT ??????