Community discussions

MikroTik App
 
jbowsher
just joined
Topic Author
Posts: 12
Joined: Tue Jul 01, 2008 12:17 am
Location: Rensselaer, IN
Contact:

UPS power monitor script errors

Wed Jun 03, 2009 1:04 am

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
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7054
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: UPS power monitor script errors

Wed Jun 03, 2009 12:49 pm

what is the line number where first syntax error appears?
 
jbowsher
just joined
Topic Author
Posts: 12
Joined: Tue Jul 01, 2008 12:17 am
Location: Rensselaer, IN
Contact:

Re: UPS power monitor script errors

Thu Jun 04, 2009 11:16 pm

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)
}
 
jbowsher
just joined
Topic Author
Posts: 12
Joined: Tue Jul 01, 2008 12:17 am
Location: Rensselaer, IN
Contact:

Re: UPS power monitor script errors

Wed Jun 10, 2009 5:32 pm

It says line 26 is the culprit...I really need some help with this, thank you in advance for any possible solutions
 
User avatar
matrot2
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Thu Jun 25, 2009 12:34 pm

Re: UPS power monitor script errors

Sat Jul 04, 2009 3:17 pm

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
You do not have the required permissions to view the files attached to this post.
 
odie
Member Candidate
Member Candidate
Posts: 216
Joined: Wed Mar 23, 2005 8:31 am
Location: Austria
Contact:

Re: UPS power monitor script errors

Sat Jul 04, 2009 10:18 pm

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 .....
 
jbowsher
just joined
Topic Author
Posts: 12
Joined: Tue Jul 01, 2008 12:17 am
Location: Rensselaer, IN
Contact:

Re: UPS power monitor script errors

Fri Jun 11, 2010 6:10 pm

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!

Who is online

Users browsing this forum: No registered users and 23 guests