Hi folks,
I'm trying to get to grips with NUT. Thedocumentation for the UCI enabled OpenWRT package is quite... rudimentary. And theofficial NUT documentaion makes a lot of assumptions around configuration if you installed from the distro packages (for Debian etc).
I've got as far as configuring the driver and setting up the server and users. Also got the local monitor working and I can query the UPS using upsc. Also have the nut client configured on my other devices (NAS, file-server and security cam recorder) and able to communicate with the NUT server. All good.
My biggest confusion now is how to get this all working in beautiful harmony. The NUT config guide lists nearly all the UCI parameters as 'required', but then shows 'working examples' with them all omitted. There is no description of the 'default' behaviour if it's left like this. Maybe it does nothing, maybe it auto-magically shuts everyting down when the power fails. I just don't know.
What I want to ultimately acheive is this, upon a power failure:
- High power devices (NAS and file-server) are commanded to shutdown cleanly immediately. I think this is done by putting an 'EXEC' script in the upsmon clients on these devices to run "/sbin/shutdown now" on the 'ONBATT' notification. Easy enough.
- Upon 'low battery' warning from the UPS my security cam recorder is commanded to shut down. This is the most default behaviour, and I think just needs "/sbin/shutdown now" as the SHUTDOWNCMD for this upsmon client.
- After the FINALDELAY timeout the OpenWRT router (which is the UPS master) should:
- Write the current logd ring-buffer to file (logread > /root/power-fail.log)
- Make-safe the file system (go read-only)
- Finally command the UPS to cut the load-power (switching itself off in the process).
I think I understand how to acheive 1 and 2. 3 is a little trickier. The NUT user guide implies some of this is auto-magic 'You don't need to do this if installing from pacakges' but I'm not sure this applies to the OpenWRT package version. So do I need to write my own shell 'shutdown' script? The step of making the file system 'safe and read-only' is frequently covered in the NUT documentation as being something obvious and easy to acheive, and it frequently pops up in sentences like: "You should configure your system to power down the UPS after the filesystems are remounted read-only." What would this look like on an OpenWRT system? You can't simply call the 'halt' command here because you need to call the 'upsdrvctl shutdown' command to remove the power after the system is made 'safe'.
Now, a further issue I have with this, is that if the power is restored between steps 1 and 3, we enter an error state because the NAS and server will be powered off, but power will have been restored to the UPS - they wont power-cycle because there was no real power interruption. I think I can get around this by scripting Wake-On-Lan magic packets into a script to be called upon the ONLINE event - however this is going to be suseptible to race conditions.
I'd apprecaite any advice or input on this!