From f3b8dc621482d303c532656dfbf9469719e6c381 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 3 Apr 2026 01:32:59 +0200 Subject: [PATCH 1/3] clients/upsmon.c: loadconfig(): add a special message for lack of POWERDOWNFLAG on upsmon PRIMARY instances [#3391] Signed-off-by: Jim Klimov --- clients/upsmon.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/clients/upsmon.c b/clients/upsmon.c index b17fb5c715..712e6fd9f9 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -2694,12 +2694,30 @@ static void loadconfig(void) /* TOTHINK: Should this warning be limited to non-WIN32 builds? */ if (!powerdownflag) { + int is_primary = 0; + utype_t *ups; + + for (ups = firstups; ups != NULL; ups = (utype_t *)ups->next) { + if (flag_isset(ups->status, ST_PRIMARY)) { + is_primary = 1; + break; + } + } + upslogx(LOG_WARNING, "No POWERDOWNFLAG value was configured in %s!", configfile); upslogx(LOG_INFO, "POWERDOWNFLAG should be a path to file that is normally " "writeable for root user, and remains at least readable " "late in shutdown after all unmounting completes."); + + if (is_primary) + upslogx(LOG_WARNING, "This upsmon instance is PRIMARY " + "for at least one device, but would not be able " + "to arrange its power-cycling when needed, " + "in the end of handling a power outage.\n" + "In case of a power-race condition, this can " + "leave your computer(s) indefinitely halted."); } } From 881f4d5e0139ac4c1120f16a42debe281829efb4 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 3 Apr 2026 01:47:56 +0200 Subject: [PATCH 2/3] docs/config-notes.txt: more clarifications about POWERDOWNFLAG file [#3391] Signed-off-by: Jim Klimov --- docs/config-notes.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/config-notes.txt b/docs/config-notes.txt index 12e139b3a8..e4450bada9 100644 --- a/docs/config-notes.txt +++ b/docs/config-notes.txt @@ -675,8 +675,24 @@ during a power failure when low battery is reached. We will test for the presence of this file in a later step. +It is recommended to use a volatile file system, which is re-created +during boot, like `/run` or `/var/run` on many OSes. Historic default +was under `/etc` where unprivileged users could not write, but a +persistent file could confuse the later shutdowns if it was not removed. + POWERDOWNFLAG /etc/killpower +As far as NUT is concerned, this should be configured on any `upsmon` +instance which is "primary" for any device that may be commanded to +shut down, and is powered by same device. + +Other shutdown scripts, on "primary" or "secondary" systems are however +welcome to check for the time-constrained shutdown due to power outage, +in case they need to balance graceful vs. urgent activities (e.g. how +long to wait for their client-server disconnection). + +The `upsmon -K` command should be used for such check. + References: man pages: linkman:upsmon[8], linkman:upsmon.conf[5] From a13da915eb95b660c74e7e2a3b3ea4a7aef44555 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 3 Apr 2026 02:00:33 +0200 Subject: [PATCH 3/3] clients/upsmon.c, NEWS.adoc: loadconfig(): extend the special message for lack of POWERDOWNFLAG on upsmon non-PRIMARY instances, stress if this server is fed by an UPS it is PRIMARY for [#3391] Signed-off-by: Jim Klimov --- NEWS.adoc | 1 + clients/upsmon.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 7b841b9a55..25d2c8d4ca 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -382,6 +382,7 @@ but the `nutshutdown` script would bail out quickly and quietly. [PR #3008] long delays did not happen in practice. [issues #2133 and #3084, PR #3086] * Make use of `setproctag()` and `getproctag()` to report parent/child process names. [#3084] + * Clarify the warning about lack of `POWERDOWNFLAG` in configuration. [#3391] * Introduced a `SHUTDOWN_HOSTSYNC` notification message, to report that the primary `upsmon` initiated the shutdown and has some secondaries to wait for first. [#3084] diff --git a/clients/upsmon.c b/clients/upsmon.c index 712e6fd9f9..8da491226c 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -2694,13 +2694,16 @@ static void loadconfig(void) /* TOTHINK: Should this warning be limited to non-WIN32 builds? */ if (!powerdownflag) { - int is_primary = 0; + int is_primary = 0, is_fed = 0; utype_t *ups; for (ups = firstups; ups != NULL; ups = (utype_t *)ups->next) { if (flag_isset(ups->status, ST_PRIMARY)) { is_primary = 1; - break; + if (ups->pv > 0) { + is_fed = 1; + break; + } } } @@ -2713,11 +2716,18 @@ static void loadconfig(void) if (is_primary) upslogx(LOG_WARNING, "This upsmon instance is PRIMARY " - "for at least one device, but would not be able " + "for at least one device%s, but would not be able " "to arrange its power-cycling when needed, " "in the end of handling a power outage.\n" "In case of a power-race condition, this can " - "leave your computer(s) indefinitely halted."); + "leave your computer(s) indefinitely halted.", + is_fed ? " that feeds it" : ""); + else + upslogx(LOG_WARNING, "This upsmon instance is not a " + "PRIMARY for any device, so this can be of " + "little concern unless other shutdown routines " + "on your system also consult it to act fast " + "during an outage."); } }