Support sleep/hibernate integration (generally and with systemd in particular) #1833
Labels
documentation
service/daemon start/stop
General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug
systemd
Milestone
There were several discussions in the past about NUT daemons emitting messages like "Data stale" when a system wakes up after prolonged sleep. One particular use-case is putting a system into hibernation when an UPS goes depleted, or into sleep when on-battery (hoping the lone RAM's power draw can be kept up for hours). This is not a platform-specific issue, everybody might do it, but it may have platform-specific optimal solutions (and/or general ones).
The messages make sense technically (lots of time passed since last poll) but seem confusing to some users and pollute the console cluttered by various subsystems after wake-up.
This issue is about exploring ways to integrate with service management frameworks like systemd to "know" a sleep happened, e.g. deal with dependencies on/against https://www.freedesktop.org/software/systemd/man/systemd-suspend.service.html family of units, or deliver hooks for them (example in https://blog.christophersmart.com/2016/05/11/running-scripts-before-and-after-suspend-with-systemd/ but official doc warns not to - deemed local hacks), or explore its "Inhibitor interface" per https://blog.christophersmart.com/2016/05/11/running-scripts-before-and-after-suspend-with-systemd/ and possibly something is possible by listening to systemd dbus...
With such integration, NUT daemons would know to silently reestablish connections when the system wakes up, and maybe chirp a message about that specifically. One solution could be to use the pre/post-sleep hooks to completely stop and start NUT services and so avoid "staleness" (also possibly account for IP address changes after wake-up).
A general-purpose alternative could be to somehow watch for system clock jumps (e.g. we have a 5 or 30 second pollfreq, and suddenly last loop took tens of minutes or more), and/or possibly track "local" time (as opposed to monotonous kernel clock) to see and react to NTP/RTC time jumps - which along with loops taking too long can be due to sleep or winter/summer time changes. Again, the purpose would be to tailor the reaction (and noise made) to this situation.
Also useful would be some documentation notes (FAQ?) and/or contributed
scripts/*
for different platforms, specifically about requesting sleep/hibernation as aSHUTDOWNCMD
. Notably, such a command could take care of stopping/starting units and init-script styled services, and/or leaving flag-files for daemons to know about the intentional situation. (Service starts could be scheduled by cron/at facility, e.g. roughlyat now + 1min
generally).Enthusiasts welcome to take on this, especially those who can test it well (have systems that do go to sleep while monitoring)!
The text was updated successfully, but these errors were encountered: