UPS power monitor script errors

I am using the ups power monitor script that I found on the mikrotik wiki for RouterOS ver. 3.x, but when I try to run it on a RB433AH with RouterOS ver. 3.23 it gives me several syntax errors and in the notes of the script it tells me not to modify the section that is giving me the errors. If anyone can help me I would appreciate it!

Thanks,
Josh

what is the line number where first syntax error appears?

Here is a copy of the script, I just removed the mail server and made up a mail from address to post here, but basically when it gets to {:set curonbatt $"on-battery"; :set curcharge $"battery-charge"} it then highlights all the c's and m's in the script that are after "$" and gives errors for each line some are syntax errors some are invalid entry errors.

Josh



\

UPS-Script powerfail

(c) steinmann und weidinger OEG

www.stone-rich.at

Watches ups status and sends emails on powerfail and battery low.

This script will FAIL if:

- Policies write, test, and read are not set

- The system name contains non-standard characters (space, /, ...)

- The UPS is not named ups1

This script was tested up to ROS 3.3

user-configurable parameters below:

:local mailserver [:resolve host]
:local mailfrom "mail@powerscript.com"
:local mailto "jbowsher@midwaynet.net"

do NOT make changes below!

:local battalarm 15
:local battok 40

:global flagonbatt
:global flagbattlow
:local curonbatt
:local curcharge

:local sysname [/system identity get name]
:local datetime ([/system clock get date] . " " . [/system clock get time])

First run? If so, we need to initialize the global flags

:if (("-" . $flagonbatt)="-") do={:set flagonbatt 0}
:if (("-" . $flagbattlow)="-") do={:set flagbattlow 0}

:set curonbatt false
:set curcharge 100
/system ups monitor [/system ups find name="ups1"] once do={:set curonbatt $"on-battery"; :set curcharge $"battery-charge"}

:if (($curonbatt) && ($flagonbatt=0)) do={
:set flagonbatt 1
/tool e-mail send from=($mailfrom) to=($mailto) server=($mailserver) subject=($sysname . ": Power failure!") body=($sysname . " is on battery since " . $datetime)
:log info ("Power-Fail: EMail sent to " . $mailto)
}

:if ((!$curonbatt) && ($flagonbatt=1)) do={
:set flagonbatt 0
/tool e-mail send from=($mailfrom) to=($mailto) server=($mailserver) subject=($sysname . ": Power is back") body=($sysname . " is back on power since " . $datetime)
:log info ("Power-Restore: Email sent to " . $mailto)
}

:if (($curcharge <= $battalarm) && ($flagbattlow=0)) do={
:set flagbattlow 1
/tool e-mail send from=($mailfrom) to=($mailto) server=($mailserver) subject=($sysname . ": Low battery!") body=($sysname . " battery is at " . $curcharge . "%! " . $datetime)
:log info ("Batt-Low: Email sent to " . $mailto)
}

:if (($curcharge >= $battok) && ($flagbattlow=1)) do={
:set flagbattlow 0
/tool e-mail send from=($mailfrom) to=($mailto) server=($mailserver) subject=($sysname . ": Battery recharged") body=($sysname . " Battery recharged to " . $curcharge . "% " . $datetime)
:log info ("Batt-Recharged: Email sent to " . $mailto)
}

It says line 26 is the culprit…I really need some help with this, thank you in advance for any possible solutions

There is ready decision UPS and UPS monitor for a mikrotik.
http://tandem.ck.ua/ups_mtm.php
http://local.com.ua/forum/index.php?showtopic=15362
UPS-MK-Monitor1.jpg

copy the files you can download onto your router via winbox ond then do an “Import” of that file on the local console
this keeps the syntax. we have seen problems when you just copy and paste the script into the script editor.

and dont forget to set the sceduler to start the ups script every few minutes or less.

our ups moduls from the Wiki also can regualte a cooling fan for outdoor cabinets and also monitors the temperature …

I got it working a while back just never posted to let you guys know. It works like a top and when you have equipment on grain elevators where power is on and off a lot in the spring and fall it is nice to know when it switches to battery power via txt message! Thanks for all the posts!