Hi, I have written a script that when run, emails the result of the ups.
What I would like to do is make it so that it ONLY emails when the UPS is on battery, and then loops back and continually monitors the UPS until the power is restored, at which time it completes the script and sends the power restored message. Any help would be very much appreciated
Kind Regards Murray
:global datetime ([/system clock get time] . " - " . [:pick[/system clock get date] 4 6] . “-” . [:pick [/system clock get date]0 3] . “-” . [:pick[/system clock get date] 7 11])
/system ups monitor [/system ups find name “ups2”] once do {
:if ($on-battery=“yes”) do {
/tool e-mail send to=“email.address@isp.com.au” subject=("Power Failure At " . $datetime) body=(“Power Failure at at " . $datetime)
}
}
/system ups monitor [/system ups find name “ups2”] once do {
:if (!$on-battery=“yes”) do {
/tool e-mail send to=“email.address@isp.com.au” subject=(” Power Restored At " . $datetime) body=("Power Restored at " . $datetime)
}
}
Thanks to all who took the time to view this post. I have managed to fix the proble using two scripts. There are probably far more elegant ways of doing it. Script A runs once a minute. Script B runs every half hour - this simply resets the trigger and sends another email if power is still off.
I would be very interested to hear from anyone who has done this an easier way.
Kind Regards Murray
Script A (scheduled to run every minute)
:global datetime ([/system clock get time] . " - " . [:pick[/system clock get date] 4 6] . “-” . [:pick [/system clock get date]0 3] . “-” . [:pick[/system clock get date] 7 11])
/system ups monitor [/system ups find name “ups1”] once do {
:if ($on-battery=“yes”) do {:set trigger ($trigger + 1)
}
}
:if ($trigger=1) do {/tool e-mail send to=my.email@isp.com.au subject=("Power Failure At " . $datetime) body=(“Power Failure at office at " . $datetime)
}
/system ups monitor [/system ups find name “ups1”] once do {
:if (($trigger > 0) && (!$on-battery=“yes”)) do {
/tool e-mail send to=my.email@isp.com.au subject=(” Power Restored At " . $datetime) body=(“Power Restored at office” . $datetime)
}
}
/system ups monitor [/system ups find name “ups1”] once do {
:if (($trigger > 0) && (!$on-battery=“yes”)) do {:set trigger 0
}
}
HI,
Sorry but these scripts must be insterted into scheduler or only as script?
And… Script B (:global trigger 0) must be included into:
/system ups monitor [/system ups find name “ups1”] once do {
:if ($on-battery=“yes”) do {:set trigger ($trigger + 1)
}
}
:if ($trigger=1) do {/tool e-mail send to=my.email@isp.com.au subject=("Power Failure At " . $datetime) body=(“Power Failure at office at " . $datetime)
}
/system ups monitor [/system ups find name “ups1”] once do {
:if (($trigger > 0) && (!$on-battery=“yes”)) do {
/tool e-mail send to=my.email@isp.com.au subject=(” Power Restored At " . $datetime) body=(“Power Restored at office” . $datetime)
}
}
/system ups monitor [/system ups find name “ups1”] once do {
:if (($trigger > 0) && (!$on-battery=“yes”)) do {:set trigger 0
}
}
Hi Xandor, enter the two scripts and call them different names. After entering the two scrips, set scheduler to run the main script say every minute and the secondary script to run say every half an hour.
The result is that every minute, MT OS checks to see if the UPS is running on battery, as soon as it does, it sends an email (I used it through an SMS gateway to message my phone). It the starts checking for mains to be restored and sends another message when this happens.
The function of the second script is to cause the first script to reset and send another email if the UPS is still running on batteries after that time. Its a bit simplistic because the second script running every half hour may reset the first script almost immediately if the UPS goes onto battery just before the half hour is up. Its not a perfect script, but it works well for me.
Hi Exandor - not sure which question you are refering to? If it is the Question about which sms gateway I use, I have already posted the URL to there web sight (here it is again). I hope this helps. If you were refering to an early question, let me know which one.