Reboot Boards due to low Memory with notification - MikroTik Script RouterOS

set this in scheduler to get lost memory back and to get a reboot when it needs to do this

:global datum [/system clock get date];
:global time [/system clock get time];
/system resource
:if ([get free-memory]< 25000) do=[
/tool e-mail send server=*.*.*.* to="alert@yours.net" subject=[/system identity get name] 
from="alert@yours.net" body=(" on $datum at $time the memory on this repeater got to ", [/system resource 
get free-memory])
/system reboot;
]};
on the if statement you will need to set the 25000 depending on board type IE 532a = 25000 153 = 12000 and so on I put this in scheduler to run at 3am once a day

Using percentages

:global datum [/system clock get date];
:global time [/system clock get time];
:local percentfree ((100 * [/system resource get free-memory]) / [/system resource get total-memory])

/system resource
:if ($percentfree < 5) do={
  /tool e-mail send server=*.*.*.* to="alert@yours.net" subject=[/system identity get name] from="alert@yours.net" body=(" on $datum at $time the memory on this repeater got to ", [/system resource get free-memory])
  /system reboot;
};
Will notify and reboot if free memory < 5%

Credit: www.mikrotik.com