I like to specify how long my server should run on the battery rather than run till the battery is flagged as low.
Running a battery until is is very low can cause issues with the long term life of the battery.
Impact
When a user has not updated their UPS shutdown timer to compensate for it getting old can lead to an immediate unexpected hard shutdown of a server when the UPS fails early
Proposed Feature
Add a new shutdown mode which is a hybrid of UPS goes on battery and UPS reaches low battery.
So the option would run like the UPS goes on battery option but have a checkbox titled If low battery is flagged, begin shutdown procedure immediately
User Story
A user years ago set a 30 minute timer on UPS goes on battery and his battery could last for 45 minutes, but now his battery can only handle 20 minutes but he does not know this, so his server with suffer a hard power down if it ever had to use the battery for longer that 20 minutes.
With my option, his negligence would not matter as much because if he had set this option the low battery trigger would override his 30 minute timer and his server would be safe.
I just tested this. Shutdown mode “UPS goes on battery” actually acts the same even if not explicitly stated.
If it detects low battery (when on battery) it executes immediate shutdown.
So hybrid mode is not needed.
Well, I tried to implement the hybrid mode you asked about, sent pull request and then found out it’s not needed so I closed it again
Now I am looking though code and docs to find out why exactly it shutdowns.
I tried it on self-built nightly in VM and dummy-ups driver. When I forced OB LB (on battery, low battery) flags it did shutdown even when on timer.
I also tested on stable release 24.04.2 in VM.
After reading this 6. Configuration notes and looking through Truenas code I think it’s inherent behavior of NUT.
Because I cant find any code in Truenas middleware that would trigger it otherwise.
Ok, I think I finally understand what is going on.
It starts in main NUT code. It looks like when certain conditions are met it sets FSD (force shutdown) flag. And UPS on battery and with low battery is one of the conditions that triggers it.
Then Truenas code upssched.conf.mako takes over and when it sees FSD flag it executes NOTIFY-FSD.
And finally when UPS.py script sees that notification it makes its own checks and performs forced shutdown. And because it uses upsmon it will perform either default command of whatever you specify in Shutdown Command in UPS configuration.
I hope i am not totally wrong
Either way I would say this is a feature. It just needs to be better documented so people know even if they use “UPS goes on battery” option it will still perform immediate shutdown if UPS goes on Low Battery.
Yeah, you are right. If I am reading that correctly then UPS.py performs shutdown with command upsmon -c fsd
This in turn executes SHUTDOWNCMD as defined in upsmon.conf which is by default set as /sbin/shutdown -P now but can be changed in Truenas UI, UPS service.