I have found very strange issue with global variables in "netwatch" scripts. When user logged in (via winbox or ssh, doesn't matter) global variables in "up" and "down" scripts works fine, as expected.
But if user not logged in, global variable created by script lasts only about 10 seconds, and then disappears. (for example, netwatch executes "down" script normally (i see email sent by that script), but if i wait for about 15-20 seconds and log in, there are no variables in "environment". BUT! if I log in within 10 sec. after script execution, variables exist!)
Scripts
Down script
:global isdown;
:local email "<my email>";
:local downtime [/system clock get time];
:local downdate [/system clock get date];
:set $isdown "true";
/tool e-mail send to=$email subject="subject" body="host is down :-( Date: $downdate Time: $downtime";
Up script
:global isdown;
:local email "<my email>";
:local uptime [/system clock get time];
:local update [/system clock get date];
if ($isdown="true") do={
:set $isdown "false";
/tool e-mail send to=$email subject="subject" body="host is UP! Date: $update Time: $uptime";
}
Any ideas where did it go wrong?
RouterOs ver. 6.40.4, hap ac lite...