I am using a script for monitoring and alerting UPS state,
After upgrade to 6.3 the script stops working correctly and I have suspiction, that it did not defines global variables well.
#declaration
:global flagonbatt
:local curonbatt
\
First run? If so, we need to initialize the global flags
:if (("-" . $flagonbatt)="-") do={:set flagonbatt 0}
:if (("-" . $flagbattlow)="-") do={:set flagbattlow 0}
/system ups monitor [/system ups find name="ups1"] once do={:set curonbatt $"on-battery";}
:if (($curonbatt) && ($flagonbatt=0)) do={
:set flagonbatt 1
:log info ("Power-Fail: .........)
}
:if ((!$curonbatt) && ($flagonbatt=1)) do={
:set flagonbatt 0
:log info ("Power-Restore: .........)
}
After running the script I don't see flagonbatt variable in /system script environment. On older ROuterOS versions (4.16), this works OK.
I have searched for any difference in scripting in v 6.x, but I did not found anything helpful.
Do anybody have any idea what is wrong there ?
Thanks.
Jiri