For another router running another firmware with apcupsd, I got log events such as:
2022-07-09 09:46:28 -0400 Power failure.
2022-07-09 09:46:29 -0400 Power is back. UPS running on mains.
2022-07-12 05:52:20 -0400 Power failure.
2022-07-12 05:52:26 -0400 Running on UPS batteries.
For my current 22.03.3 router with an APC usbhid-ups directly connected, I had stall issues with apcupsd, so I'm running nut instead. Since nut is modular, I'm not sure whether I would require nut's upsmon or upslog for logging the events to the standard logd (I think upsmon it would make more sense, 'though).
For upsmon or upslog I notice the configuration requires to define a poll interval, but I don't know whether the power events I want to record are pushed by the UPS, or has to be pulled from nut. And I'm not sure if polling the UPS every second would be the proper way to do this.
One thing about apcupsd is that it is pretty dead in the water. If I remember right, last upgrade it had on the webpage was of 2016, 7years ago…
I had some issues with it also with my last ups.
The last APC UPS I bought, I bought with a add-on network card and then it runs as a little webbserver by it own and it can send its logs to a logserver.
So if you ask me, the world and APC has run away from apcupsd.
I won't discuss that, except that apcupsd works fine over FreshTomato and over a fork of OpenWrt 18.06, but not on the official OpenWrt 22.03.3. And for the router I want to use this, I could only downgrade to 22.03.0, so I rather don't.
That's why I've messing with nut, but if apcupsd is orphan, nut is not straight forward. i.e. I've figured out several parts, found some issues that has been fixed with the help of this community for future releases, and now I'm scratching my head at the events part.
Well, the thing is that this is OpenWrt forum and not apcupsd forum so what are we supposed to discuss?
But there is problems with apcupsd on raspberry also.
But these kind of packages sit right in between a hardware UPS and a computer running evolving linux kernel. If that link stops evolve one day then it is pretty much a guarantee fact that something will break from one or the other side or both sides as the years move along.
Of course it works with 18.06, they are pretty much the same age. But 18.06 is also a dead fish in the water that no one cares about anymore.
Of course there are many ways to do this, but because my routers are the ones running 24/7, I prefer to use it. For my environment I have several choices, either to downgrade router and firmware in order to use apcupsd with OpenWrt, or find another router that allows me to try all the intermediate releases in order to find when it broke, or forget apcupsd and use "Network UPS Tools" --which is what I'm currently aiming at--, or forget OpenWrt and its features, and resign to use a less powerful kernel/firmware.
So far I've tried nut with two routers and two APC usbhid UPSs, one router with a old OpenWrt fork for a couple of hours, and the other with official 22.03.3 for two weeks. I have found several issues (that already has been improved and shared), but I haven't lost connection with any UPS.
What I haven't found yet is the way to log the surges and brownouts, as I used to do easily with apcupsd:
root@oldrouter:~# cat /var/log/apcupsd.events
2022-07-29 16:19:59 -0400 apcupsd 3.14.14 (31 May 2016) debian startup succeeded
2022-08-04 17:48:51 -0400 Power failure.
2022-08-04 17:48:53 -0400 Power is back. UPS running on mains.
2022-08-04 18:19:55 -0400 Power failure.
2022-08-04 18:19:57 -0400 Power is back. UPS running on mains.
2022-08-13 15:27:39 -0400 Power failure.
2022-08-13 15:27:43 -0400 Power is back. UPS running on mains.
2022-08-15 22:11:40 -0400 Power failure.
2022-08-15 22:11:42 -0400 Power is back. UPS running on mains.
2022-08-20 08:37:45 -0400 Power failure.
2022-08-20 08:37:47 -0400 Power is back. UPS running on mains.
2022-09-02 07:18:37 -0400 UPS Self Test switch to battery.
2022-09-02 07:18:45 -0400 UPS Self Test completed: Not supported
2022-09-03 16:15:07 -0400 Power failure.
2022-09-03 16:15:08 -0400 Power is back. UPS running on mains
2022-09-06 14:34:23 -0400 Power failure.
2022-09-06 14:34:25 -0400 Power is back. UPS running on mains
2022-09-17 14:40:42 -0400 Power failure.
2022-09-17 14:40:44 -0400 Power is back. UPS running on mains
2022-09-21 03:57:26 -0400 Power failure.
2022-09-21 03:57:27 -0400 Power is back. UPS running on mains
2022-09-26 04:33:28 -0400 Power failure.
2022-09-26 04:33:30 -0400 Power is back. UPS running on mains
2022-09-26 05:07:15 -0400 Power failure.
2022-09-26 05:07:17 -0400 Power is back. UPS running on mains
2022-09-27 15:42:46 -0400 Power failure.
2022-09-27 15:42:48 -0400 Power is back. UPS running on mains
2022-09-30 18:46:15 -0400 Power failure.
2022-09-30 18:46:16 -0400 Power is back. UPS running on mains
2022-10-06 11:34:16 -0400 Power failure.
2022-10-06 11:34:18 -0400 Power is back. UPS running on mains
2022-10-06 11:49:38 -0400 Power failure.
2022-10-06 11:49:44 -0400 Running on UPS batteries.
2022-10-06 12:12:32 -0400 Reached remaining time percentage limit on batteries.
2022-10-06 12:12:32 -0400 Initiating system shutdown!
2022-10-06 12:12:32 -0400 Unable to create /usr/local/apcupsd/powerfail: ERR=Read-only file system
2022-10-06 12:12:32 -0400 User logins prohibited
I want to do the same with nut, so if somebody can help me with how to do the configuration, I would appreciate it.
Sun Apr 16 17:57:04 2023 daemon.err upsmon[6010]: 1068352.597730 Your UPS is on battery.
Sun Apr 16 17:57:14 2023 daemon.err upsmon[6010]: 1068362.617739 Your UPS is back on line power.
I use luci-app-nut to configure it, on its Monitor tab you have to select "Write to syslog" for the events you want logged, you can also edit the messages to be logged. I use the default poll interval.
So do I need to add/customize the events I want to log, or it's supposed to be using the defaults at the moment?
On the other hand, most of the events last 1 second or 2, so if I poll every 5 seconds, probably I will miss most of them. For apcupsd I was thinking the events were pushed from the UPS instead of being polled from the package. So for nut to poll is the way it works?
Not all messages of interest are logged by default, so yes have a look at the Network UPS Tools (Monitor) on luci and add/select more if you want them. Editing the actual messages text is optional and down to personal preference.
The poll frequency is just nut polling the UPS to make sure it's alive, while the power events are sent from the UPS to nut as they happen regardless of the polling frequency.
Below from the usbhid-ups man page:
pollfreq=num
Set polling frequency, in seconds, to reduce the USB data flow. Between two polling requests, the driver will wait for interrupts (aka UPS notifications), which are data changes returned by the UPS by itself. This mechanism allow to avoid or reduce staleness message, due to the UPS being temporarily overloaded with too much polling requests. The default value is 30 (in seconds).
Today I got a "power is back" event, but it didn't log the power failure event (that's odd). Maybe it's something related with the log levels, I'm relaxing the log level filtering to "Error", and keep looking.