networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
2.07k stars 351 forks source link

two notifytypes together? #1952

Open GustelDE opened 1 year ago

GustelDE commented 1 year ago

Hi there,

not a probelm but a question I found no answer (or I googled the wrong stuff). Is it possible to combine two notifytypes together in the UPSSCHED.CONF?

Id like to cover the condition ONBATT + COMMBAD or in other words, a action should be called if the COMM to the UPS is lost ONLY when the UPS was ON BATT?

I know this from APCs PowerChute which is quite handy, if the switch fails while on BATT.

jimklimov commented 1 year ago

Not sure OTOH, I'd suggest to check the code. That said, upssched keeps track of certain conditions with a timer, and if they persist long enough (not a fluke) calls the handling script with this or that parameter.

By itself it is one of possible NOTIFYCMD handlers for upsmon daemon, which is a NUT protocol client of a data server (upsd). And this one certainly has handling for ONBATT+COMMBAD cases as a cause for emergency shutdown of secondary systems which lose the connection to their primary (where upsd runs), assuming some other UPS failed and took out the networking gear. I don't think an upsmon in primary mode does that, since it is typically on same system as upsd, but again - better check in source or by experiment (maybe with a dummy SHUTDOWNCMD to not actually power down your machines).

Note that normally the primary upsmon eventually detects a critical power state (definitions may vary) and raises an FSD (Forced Shut Down) flag in the data server. Then all secondaries are expected to shut down ASAP and disconnect as part of their late endgame (control over lateness varies per OS). When the primary is left as the only client, or a timeout for secondaries to go off has passed, the primary goes down and usually tells the UPS to power off or power-cycle.

Once FSD has started, it is treated as uninterruptible: everyone must reboot eventually for the server farm to be in a definitive state. In cases where you know what you're doing, you can restart upsd to clear the FSD flag (assuming wall power state and battery charge won't cause it to be raised again).