Reset UPS shutdown timer when shutdown mode changes
Any configuration in FreeNAS 11 using stable GUI
FreeBSD 11.0-STABLE (FreeNAS.amd64) #0 r313908+d7d07647f69(freenas/11.0-stable):
Switching from Shutdown mode: UPS reaches low battery to -> UPS goes on battery; you're then allowed to enter a shutdown timer in seconds, which specifies the FINALDELAY tag in upsmon.conf
However after saving, if shutdown mode is then switched back to UPS reaches low battery, FINALDELAY is kept at the original value, negating the change the user just made, leading to unintended results.
Expected behavior is FINALDELAY to either be cleared completely or to be reset to the default value specified by NUT's configuration of 5 seconds.
#7 Updated by Roger Hayter over 1 year ago
When last reported (a few years ago) this bug was marked 'not to be fixed' I think. The workaround is to change and save the time delay (as 15sec or whatever is sensible) before changing mode. (The shutdown timer mode shouldn't be altering FINALDELAY anyway, as it is unnecessary and makes that mode work incorrectly.)
#8 Updated by Charles Goetzman over 1 year ago
I was having trouble configuring a slave device because of this, and really any increase in FINALDELAY is unsafe for a slave. If a slave's finaldelay is longer than the master's HOSTSYNC, you will not run your SHUTDOWNCMD before you lose power.
Even for a master it shouldn't be using finaldelay to hold off shutdown, that's what the upssched timers are for. Finaldelay only determines the time between notifycmd and shutdowncmd once upsmon has already decided to shutdown. Since notifycmd is only used to send an email in FreeNAS's upssched config, there's no reason to have any significant delay between the two. Also if power is restored during a long finaldelay, you will shutdown anyway for no reason. It should probably just be fixed at 5 seconds like the examples configs show.
#17 Updated by Roger Hayter over 1 year ago
If your code does what the title says it is probably the wrong thing.
1. FINALDELAY in upsmon.conf should stay at 5 and the timer setting code should not alter it. (It should only alter the timer in upssched.conf and this does not need resetting with mode change.)
2. Just for the sake of those current FreeNAS installs that have previously altered FINALDELAY it should be initialised to 5 at boot or UPS service start and then left untouched.