bgp peer disable/enable script based on packet loss

Grretings. I’ll greatly appreciate some help with script as my scripting and programming skills are below zero.
I need bgp peer which “name” ends with “asr1” to be disable at site-A-router if icmp packet loss to WAN ip address at site-B-router is above 5%.

I tried to figure this out myself and ended up with script below, but it does not work :frowning:

# VARIABLES
:local asr1 "212.2.33.84";
:local pingCount 20;
:local stableConnectionFrom 95;
:local quality ([/ping count=$pingCount $asr1] * 100 / $pingCount)
# Connection quality check and bgp peers disable or enable
:if ($quality < $stableConnectionFrom) do={
/routing bgp peer disable [find where name~"asr1" and disabled=no]
} 
elese={
do={/routing bgp peer enable [find where name~"asr1" and disabled=yes]
}
}

Thanks in advance.

Post it in Code tags and tabs, makes it easier to read.
PS I have not tested it.
fixed: elese-else
removed extra: }
removed: do
removed not needed ; at end of lines

# VARIABLES
:local asr1 "212.2.33.84"
:local pingCount 20
:local stableConnectionFrom 95
:local quality ([/ping count=$pingCount $asr1] * 100 / $pingCount)
# Connection quality check and bgp peers disable or enable
:if ($quality < $stableConnectionFrom) do={
	/routing bgp peer disable [find where name~"asr1" and disabled=no]
} else={
	/routing bgp peer enable [find where name~"asr1" and disabled=yes]
}

Thank you for editing the script, but it does not work still despite I’ve made artificial icmp packet drop.

I found some issue in CLI print mode. After “else” operator “=” is marked red as if there is some syntax error.

UPDT: when doing copy-paste missed a “space” before “else”. Now script is working.
Thanks for help!