Code: Select all
/system ups monitor 0
as well as lots of other data.
And, when the line voltage drops, I can see log entries:
Code: Select all
USB UPS AC power on
Is there a way to record and log this directly, or using a script?
Thank you.
/system ups monitor 0
USB UPS AC power on
my problem is I can't find/get the voltage data from the command lineI'm supposed to be on my way home already so I'm not going to write it for you.
But I'd do it like this:
:if(ups on battery) do={:log voltage}
Then add it to the scheduler and run it every 00:00:01.
Note that this will be a resource hog and will fill a 1000 entries long log in 15 minutes. Setting the scheduler to every 5 seconds will lessen the impact on the cpu somewhat and allow for about an hour worth of readings.
[admin@371hEX] /system/ups> print proplist=
Flags: X - disabled; I - invalid
0 name="ups1" port=usbhid1 offline-time=0s min-runtime=never
alarm-setting=immediate
model="Back-UPS RS 700G FW:856.L8 -P.D USB FW:L8 -P" serial="0B2252N07530"
manufacture-date="2022-12-22" load=8% on-line=yes
nominal-battery-voltage=12V
Wow!It isn't a property. As an aside I'm not sure why load appears in both properties and monitor values, logically it would only be in the latter with the other measured data.
To display from the command line :put ([/system/ups/monitor 0 once as-value]->"line-voltage")
If you wish to access multiple values store the monitor output in a variable, you can then reference the array elements by name as required.
:local voltage (([/system ups monitor 0 once as-value]->"line-voltage")/100)
:log info $voltage
:if (([monitor 0 once as-value]->"on-battery") = "true") do={
:local voltage (([/system ups monitor 0 once as-value]->"line-voltage")/100)
:log info $voltage
}
I'm using the BACK-UPS RS 700G and ROS has data in the fields "on-battery" and "on-line"Do your UPS offer the “on-battery” field? While I see it mentioned in the documentation, https://help.mikrotik.com/docs/spaces/ ... 324130/UPS, my little experience is that the actual UPS implementation on Mikrotik deviates a lot from the documentation. Some of it may be due to the exact model, but some of it is just different.
Anyway, with my BackUPS BX750, I do not see a lot of the fields mentioned in the documentation, including “on-battery”. Instead, I understood the “on-line” field as meaning whether the UPS is operating on AC or battery, but I have only tested with a full disconnect, not partially dropping supply voltage.
As for triggering. MikroTik only supports polling for the vast majority of functionality, except a few cases like DHCP events and MQTT subscriptions.
:put ([/system/ups/monitor 0 once as-value]->"on-battery")
:put ([/system/ups/monitor 0 once as-value]->"on-line")
:put ([/system/ups/monitor 0 once as-value]->"line-voltage")
Thank you very much for the detailed explanation and analysis. It makes perfect sense.For what it's worth, I researched the topic of UPS facility in Mikrotik years ago and haven't revisited the subject much. I've settled on having smart upses be used as dumb ones and only use the UPS facility in Mikrotik for the occasional peek at what it is doing.
The reason for why Mikrotik deviates from its own documentation is not on Mikrotik but on APC. Over the years, different models use different protocols (mind you these are proprietary protocols for which Schneider releases little to no documentation) and different models report different variables and field names.
The UPS facility is Mikrotik's best effort at incorporating a way of reading all the different signalling and it works surprisingly well for the most part. What I would really have liked to see is the "reboot" command incorporated for those UPSes that support it. But I understand that Mikrotik have basically given up on this as it is a really big effort for a really small userbase. And that said effort is better spent on other facilities and features for which there's a far higher demand.
Back on topic, you'll need to adapt the script for whatever your make and model UPS is reporting. Some will report "online" when running on mains and not report "on battery" at all. They just stop reporting "online". Others don't report "online" but will report "on battery" when running on batts. Again, this isn't Mikrotik's fault but APCs on how their different models signal.