From a3d51c0765f46d2bd08e22b3a6e64291e61be8b1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 25 Nov 2023 11:19:56 +0100 Subject: [PATCH 01/20] scripts/python/app/NUT-Monitor, NEWS.adoc: fix typo (qt3=>qt5) Closes: #2199 Signed-off-by: Jim Klimov --- NEWS.adoc | 2 ++ scripts/python/app/NUT-Monitor | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 711aab6d55..4bf8648fbf 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -57,6 +57,8 @@ https://github.com/networkupstools/nut/milestone/10 in their configuration) failed to apply group ownership and permissions to their Unix socket file for interaction with the local data server. [#2185, #2096] + * Dispatcher script `scripts/python/app/NUT-Monitor` referenced `py3qt3` + instead of the correct `py3qt5`. [#2199] - nut-usbinfo.pl, nut-scanner and libnutscan: * USB VendorID:ProductID support list files generated by the script for diff --git a/scripts/python/app/NUT-Monitor b/scripts/python/app/NUT-Monitor index cab270f574..ca2949aaf9 100755 --- a/scripts/python/app/NUT-Monitor +++ b/scripts/python/app/NUT-Monitor @@ -5,7 +5,7 @@ # a single simple call. # # Copyright (C): -# 2022 Jim Klimov +# 2022-2023 Jim Klimov # # License: GPLv2+ @@ -52,14 +52,14 @@ if [ -n "$PYTHON_PY2GTK2" ] && [ -n "$PYTHON_PY3QT5" ] ; then if $PREFER_PY2 ; then exec "$0"-py2gtk2 "$@" else - exec "$0"-py3qt3 "$@" + exec "$0"-py3qt5 "$@" fi else if [ -n "$PYTHON_PY2GTK2" ] ; then exec "$0"-py2gtk2 "$@" fi - if [ -n "$PYTHON_PY3QT3" ] ; then - exec "$0"-py3qt3 "$@" + if [ -n "$PYTHON_PY3QT5" ] ; then + exec "$0"-py3qt5 "$@" fi fi From 80c37880166c328ba29c24401173b4b42faaa4a9 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 25 Nov 2023 11:28:06 +0100 Subject: [PATCH 02/20] NEWS.adoc: note the fix for #2198 Signed-off-by: Jim Klimov --- NEWS.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index 4bf8648fbf..88511c629c 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -49,6 +49,8 @@ https://github.com/networkupstools/nut/milestone/10 * dstate machinery: a segmentation fault (null pointer dereference) was possible with `INSTCMD` processing of commands without parameters nor `TRACKING` identifier. [#2155] + * USB bus number detection for libusb-1.0 builds was overly zealous and + wrongly considered zero values as an error. [#2198] * `upsmon` recognition of `CAL` state could linger after the calibration activity was completed by the hardware, which led to mis-processing of shutdown triggers. Also, notification was added to report "finished From dd090a19d6d59568210f94f3029e3ca7659da083 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sat, 25 Nov 2023 11:36:42 +0100 Subject: [PATCH 03/20] scripts/python/app/NUT-Monitor, NEWS.adoc: check if implementation scripts exist before looking into them for a PYTHON* version Closes: #2201 Signed-off-by: Jim Klimov --- NEWS.adoc | 4 +++- scripts/python/app/NUT-Monitor | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 88511c629c..739a31675e 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -60,7 +60,9 @@ https://github.com/networkupstools/nut/milestone/10 to their Unix socket file for interaction with the local data server. [#2185, #2096] * Dispatcher script `scripts/python/app/NUT-Monitor` referenced `py3qt3` - instead of the correct `py3qt5`. [#2199] + instead of the correct `py3qt5`. It also tries to check both `py2gtk2` + and `py3qt5` implementations verbosely, even if one is not installed. + [#2199, #2201] - nut-usbinfo.pl, nut-scanner and libnutscan: * USB VendorID:ProductID support list files generated by the script for diff --git a/scripts/python/app/NUT-Monitor b/scripts/python/app/NUT-Monitor index ca2949aaf9..11c5a07e3b 100755 --- a/scripts/python/app/NUT-Monitor +++ b/scripts/python/app/NUT-Monitor @@ -14,8 +14,8 @@ PREFER_PY2=true # Detect which variant of NUT-Monitor we can run on the local system: -PYTHON_PY2GTK2="`head -1 "$0"-py2gtk2 | sed 's,^#!,,'`" || PYTHON_PY2GTK2="" -PYTHON_PY3QT5="`head -1 "$0"-py3qt5 | sed 's,^#!,,'`" || PYTHON_PY3QT5="" +[ -s "$0"-py2gtk2 -a -x "$0"-py2gtk2 ] && PYTHON_PY2GTK2="`head -1 "$0"-py2gtk2 | sed 's,^#!,,'`" || PYTHON_PY2GTK2="" +[ -s "$0"-py3qt5 -a -x "$0"-py3qt5 ] && PYTHON_PY3QT5="`head -1 "$0"-py3qt5 | sed 's,^#!,,'`" || PYTHON_PY3QT5="" SCRIPTDIR="`dirname "$0"`" && SCRIPTDIR="`cd "$SCRIPTDIR" && pwd`" || SCRIPTDIR="./" if [ -n "$PYTHON_PY2GTK2" ] \ From 0e45641e380036d5449ad1df87b8054ba9d010dc Mon Sep 17 00:00:00 2001 From: Laurent Bigonville Date: Mon, 27 Nov 2023 18:23:56 +0100 Subject: [PATCH 04/20] Set the DesktopFileName in scripts/python/app/NUT-Monitor-py3qt5 This binds the application with the desktop file and allow the Desktop to display the proper icon and application name. Signed-off-by: Laurent Bigonville --- NEWS.adoc | 3 +++ scripts/python/app/NUT-Monitor-py3qt5.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index 739a31675e..1fb4def0c0 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -63,6 +63,9 @@ https://github.com/networkupstools/nut/milestone/10 instead of the correct `py3qt5`. It also tries to check both `py2gtk2` and `py3qt5` implementations verbosely, even if one is not installed. [#2199, #2201] + * Set the DesktopFileName in scripts/python/app/NUT-Monitor-py3qt5, this + binds the application with the desktop file and allow the Desktop to + display the proper icon and application name. - nut-usbinfo.pl, nut-scanner and libnutscan: * USB VendorID:ProductID support list files generated by the script for diff --git a/scripts/python/app/NUT-Monitor-py3qt5.in b/scripts/python/app/NUT-Monitor-py3qt5.in index d78f4160a4..b124b946ed 100755 --- a/scripts/python/app/NUT-Monitor-py3qt5.in +++ b/scripts/python/app/NUT-Monitor-py3qt5.in @@ -29,6 +29,8 @@ # # 2022-02-20 Luke Dashjr - Version 2.0 # Port to Python 3 with PyQt5. +# 2023-11-27 Laurent Bigonville - Version 2.0.1 +# Set the DesktopFileName import PyQt5.uic @@ -80,6 +82,7 @@ class interface : self.__app = QApplication( argv ) + self.__app.setDesktopFileName("nut-monitor-py3qt5") self.__ui_file = self.__find_res_file( 'ui', "window1.ui" ) From 50dc6fb42f6b54498952cce3327b6e9876df67a2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2023 21:34:28 +0100 Subject: [PATCH 05/20] NEWS.adoc, docs/nut.dict: checking and formatting for the entry about DesktopFileName in NUT-Monitor-py3qt5 [#2205] Signed-off-by: Jim Klimov --- NEWS.adoc | 6 +++--- docs/nut.dict | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 1fb4def0c0..d205e9b90d 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -63,9 +63,9 @@ https://github.com/networkupstools/nut/milestone/10 instead of the correct `py3qt5`. It also tries to check both `py2gtk2` and `py3qt5` implementations verbosely, even if one is not installed. [#2199, #2201] - * Set the DesktopFileName in scripts/python/app/NUT-Monitor-py3qt5, this - binds the application with the desktop file and allow the Desktop to - display the proper icon and application name. + * Set the `DesktopFileName` in `scripts/python/app/NUT-Monitor-py3qt5`, + this binds the application with the desktop file and allow the Desktop + implementation to display the proper icon and application name. [#2205] - nut-usbinfo.pl, nut-scanner and libnutscan: * USB VendorID:ProductID support list files generated by the script for diff --git a/docs/nut.dict b/docs/nut.dict index 1389ae0c51..7653b5e3a0 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3420 utf-8 +personal_ws-1.1 en 3421 utf-8 AAC AAS ABI @@ -296,6 +296,7 @@ Ddtrace DeepTstFail Defensor DeltaUPSv +DesktopFileName DeviceID DeviceKit DeviceLogin From 3b49a90a8161a7042d1fdfba6bb666d811cef31b Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2023 21:36:07 +0100 Subject: [PATCH 06/20] scripts/python/app/NUT-Monitor-py3qt5.in: take a cautious approach to setDesktopFileName() Signed-off-by: Jim Klimov --- scripts/python/app/NUT-Monitor-py3qt5.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/python/app/NUT-Monitor-py3qt5.in b/scripts/python/app/NUT-Monitor-py3qt5.in index b124b946ed..a149ddaf31 100755 --- a/scripts/python/app/NUT-Monitor-py3qt5.in +++ b/scripts/python/app/NUT-Monitor-py3qt5.in @@ -29,6 +29,7 @@ # # 2022-02-20 Luke Dashjr - Version 2.0 # Port to Python 3 with PyQt5. +# # 2023-11-27 Laurent Bigonville - Version 2.0.1 # Set the DesktopFileName @@ -82,7 +83,10 @@ class interface : self.__app = QApplication( argv ) - self.__app.setDesktopFileName("nut-monitor-py3qt5") + try: + self.__app.setDesktopFileName("nut-monitor-py3qt5") + except Exception as ex: + pass self.__ui_file = self.__find_res_file( 'ui', "window1.ui" ) From 17b82b56b0a6a99bd4993fa92532736ec5581a7c Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2023 21:57:47 +0100 Subject: [PATCH 07/20] scripts/python/app/NUT-Monitor-py2gtk2.in: leave a comment to suggest using g_set_prgname() Suggested by Laurent Bigonville Currently I've failed to find a test system with Py2 + GTK2 preinstalled (the one I had was updated and half the old dependencies are missing), and did not quickly find python syntax examples for it as well. Signed-off-by: Jim Klimov --- scripts/python/app/NUT-Monitor-py2gtk2.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/python/app/NUT-Monitor-py2gtk2.in b/scripts/python/app/NUT-Monitor-py2gtk2.in index 5c16aa3a77..652132f1c8 100755 --- a/scripts/python/app/NUT-Monitor-py2gtk2.in +++ b/scripts/python/app/NUT-Monitor-py2gtk2.in @@ -75,6 +75,9 @@ class interface : ( cmd_opts, args ) = opt_parser.parse_args() + # FIXME: tell the system to not guess and definitively use + # the `nut-monitor-py2gtk2.desktop` for windowing resources: + # g_set_prgname('nut-monitor-py2gtk2') self.__glade_file = os.path.join( os.path.dirname( sys.argv[0] ), "ui/gui-1.3.glade" ) From 005eb0099a7168661cb304dcc999f9cfad7a8623 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2023 22:19:20 +0100 Subject: [PATCH 08/20] m4/nut_check_aspell.m4: AC_SUBST detected paths after checking if detected aspell is useful Signed-off-by: Jim Klimov --- m4/nut_check_aspell.m4 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/m4/nut_check_aspell.m4 b/m4/nut_check_aspell.m4 index 4fb7feaa9f..c3865b2224 100644 --- a/m4/nut_check_aspell.m4 +++ b/m4/nut_check_aspell.m4 @@ -97,12 +97,6 @@ if test -z "${nut_have_aspell_seen}"; then AC_MSG_RESULT([${ASPELL_FILTER_TEX_PATH}]) fi - AM_CONDITIONAL([HAVE_ASPELL_FILTER_LIB_PATH], [test -d "$ASPELL_FILTER_LIB_PATH"]) - AC_SUBST(ASPELL_FILTER_LIB_PATH) - AM_CONDITIONAL([HAVE_ASPELL_FILTER_SHARE_PATH], [test -d "$ASPELL_FILTER_SHARE_PATH"]) - AC_SUBST(ASPELL_FILTER_SHARE_PATH) - AM_CONDITIONAL([HAVE_ASPELL_FILTER_TEX_PATH], [test -d "$ASPELL_FILTER_TEX_PATH"]) - AC_SUBST(ASPELL_FILTER_TEX_PATH) AC_MSG_CHECKING([if aspell version can do our documentation spell checks (minimum required ${ASPELL_MIN_VERSION})]) AX_COMPARE_VERSION([${ASPELL_VERSION}], [ge], [${ASPELL_MIN_VERSION}], [ @@ -113,6 +107,13 @@ if test -z "${nut_have_aspell_seen}"; then nut_have_aspell="no" ]) + AM_CONDITIONAL([HAVE_ASPELL_FILTER_LIB_PATH], [test -d "$ASPELL_FILTER_LIB_PATH"]) + AC_SUBST(ASPELL_FILTER_LIB_PATH) + AM_CONDITIONAL([HAVE_ASPELL_FILTER_SHARE_PATH], [test -d "$ASPELL_FILTER_SHARE_PATH"]) + AC_SUBST(ASPELL_FILTER_SHARE_PATH) + AM_CONDITIONAL([HAVE_ASPELL_FILTER_TEX_PATH], [test -d "$ASPELL_FILTER_TEX_PATH"]) + AC_SUBST(ASPELL_FILTER_TEX_PATH) + dnl Notes: we also keep HAVE_ASPELL for implicit targets, such as dnl addition to "make check" target dnl ### AM_CONDITIONAL([HAVE_ASPELL], [test -n "$ASPELL"]) From e519320168435fb641a2d1c9c9b9e325a7482d08 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Mon, 27 Nov 2023 22:19:40 +0100 Subject: [PATCH 09/20] m4/nut_check_aspell.m4: run a live check if the detected aspell is useful Signed-off-by: Jim Klimov --- m4/nut_check_aspell.m4 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/m4/nut_check_aspell.m4 b/m4/nut_check_aspell.m4 index c3865b2224..9fcb960046 100644 --- a/m4/nut_check_aspell.m4 +++ b/m4/nut_check_aspell.m4 @@ -101,7 +101,19 @@ if test -z "${nut_have_aspell_seen}"; then AC_MSG_CHECKING([if aspell version can do our documentation spell checks (minimum required ${ASPELL_MIN_VERSION})]) AX_COMPARE_VERSION([${ASPELL_VERSION}], [ge], [${ASPELL_MIN_VERSION}], [ AC_MSG_RESULT(yes) - nut_have_aspell="yes" + AC_MSG_CHECKING([if detected aspell configuration works]) + dnl Roughly following docs/Makefile.am setup for "make spellcheck": + ASPELL_NUT_TEXMODE_ARGS="-t" + AS_IF([test -d "$ASPELL_FILTER_TEX_PATH"], [ASPELL_NUT_TEXMODE_ARGS="--filter-path='${ASPELL_FILTER_TEX_PATH}' ${ASPELL_NUT_TEXMODE_ARGS}"]) + res1="`echo test | ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} -d en.UTF-8 | grep test`" + res2="`echo qwer | ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} -d en.UTF-8 | grep qwer`" + AS_IF([test x"$res1" = x -a x"$res2" != x], [ + AC_MSG_RESULT(yes) + nut_have_aspell="yes" + ], [ + AC_MSG_RESULT(no) + nut_have_aspell="no" + ]) ], [ AC_MSG_RESULT(no) nut_have_aspell="no" From f7d18710df4b43b4fffba6b50374ceea2a31aad8 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Tue, 28 Nov 2023 00:44:31 +0100 Subject: [PATCH 10/20] m4/nut_check_aspell.m4: check if aspell can use the discovered tex module (binary arch match) and try to fall back to built-in defaults if not Either way, avoid an unusable `make spellcheck` which just reports a massive failure. Signed-off-by: Jim Klimov --- m4/nut_check_aspell.m4 | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/m4/nut_check_aspell.m4 b/m4/nut_check_aspell.m4 index 9fcb960046..dbccd27878 100644 --- a/m4/nut_check_aspell.m4 +++ b/m4/nut_check_aspell.m4 @@ -35,6 +35,13 @@ if test -z "${nut_have_aspell_seen}"; then ASPELL_VERSION_MINMAJ="`echo "${ASPELL_VERSION}" | sed 's,\.@<:@0-9@:>@@<:@0-9@:>@*$,,'`" + dnl FIXME: Some systems have more complicated layouts, e.g. + dnl /usr/lib/amd64/aspell-0.60/tex-filter.so + dnl /usr/lib/aspell-0.60/tex-filter.so + dnl which require matching of the `aspell` binary architecture + dnl with the module. We currently avoid the hassle thanks to a + dnl fallback to built-in paths below if this initial guesswork + dnl failed. This may need some more-direct addressing later. AC_MSG_CHECKING([for aspell "lib" filtering resources directory]) ASPELL_BINDIR="`dirname "$ASPELL"`" if test -d "${ASPELL_BINDIR}/../lib" ; then @@ -104,14 +111,37 @@ if test -z "${nut_have_aspell_seen}"; then AC_MSG_CHECKING([if detected aspell configuration works]) dnl Roughly following docs/Makefile.am setup for "make spellcheck": ASPELL_NUT_TEXMODE_ARGS="-t" - AS_IF([test -d "$ASPELL_FILTER_TEX_PATH"], [ASPELL_NUT_TEXMODE_ARGS="--filter-path='${ASPELL_FILTER_TEX_PATH}' ${ASPELL_NUT_TEXMODE_ARGS}"]) - res1="`echo test | ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} -d en.UTF-8 | grep test`" - res2="`echo qwer | ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} -d en.UTF-8 | grep qwer`" - AS_IF([test x"$res1" = x -a x"$res2" != x], [ + AS_IF([test -n "$ASPELL_FILTER_TEX_PATH" -a -d "$ASPELL_FILTER_TEX_PATH"], [ASPELL_NUT_TEXMODE_ARGS="--filter-path='${ASPELL_FILTER_TEX_PATH}' ${ASPELL_NUT_TEXMODE_ARGS}"]) + ASPELL_NUT_COMMON_ARGS="-d en -a" + dnl Using "eval" to handle quotes, in case of funny paths + out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; exec -- 2>&1; set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}`"; res0=$? + AS_IF([test x"$res0" != x0], [ + AC_MSG_NOTICE([FAILED CMD: ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}]) + AC_MSG_NOTICE([aspell result ($res0) and output: $out0]) + ]) + AS_CASE([$out0], + [*ELFCLASS*|*"wrong ELF class"*], [ + dnl Retry without the filter path, we must have caught a wrong one + dnl and *most* platforms do serve a trustworthy built-in after all: + AC_MSG_RESULT(no) + AC_MSG_CHECKING([if detected aspell configuration works with built-in paths (tweaked one finds wrong binary modules)]) + ASPELL_NUT_TEXMODE_ARGS="-t" + out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; exec -- 2>&1; set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}`"; res0=$? + AS_IF([test x"$res0" = x0], [ASPELL_FILTER_TEX_PATH=""], [ + AC_MSG_NOTICE([FAILED CMD: ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}]) + AC_MSG_NOTICE([aspell result ($res0) and output: $out0]) + ]) + ] + ) + out1="`echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS} | grep test`"; res1=$? + out2="`echo qwer | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS} | grep qwer`"; res2=$? + AS_IF([test x"$out1" = x -a x"$out2" != x], [ AC_MSG_RESULT(yes) nut_have_aspell="yes" ], [ AC_MSG_RESULT(no) + AC_MSG_NOTICE([aspell result ($res1) for 'test' (should be empty): $out1]) + AC_MSG_NOTICE([aspell result ($res2) for 'qwer' (should have suggestions): $out2]) nut_have_aspell="no" ]) ], [ From fc34d995462fed91b0ba2369aee67bc2792a3cda Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 11:25:54 +0100 Subject: [PATCH 11/20] docs/man/upsmon.txt, docs/man/upsmon.conf.txt, conf/upsmon.conf.sample.in: clarify wording about POLLFAIL_LOG_THROTTLE_MAX "standard behavior" Signed-off-by: Jim Klimov --- conf/upsmon.conf.sample.in | 5 +++-- docs/man/upsmon.conf.txt | 7 ++++--- docs/man/upsmon.txt | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/conf/upsmon.conf.sample.in b/conf/upsmon.conf.sample.in index d555fec796..cafa7448b8 100644 --- a/conf/upsmon.conf.sample.in +++ b/conf/upsmon.conf.sample.in @@ -415,8 +415,9 @@ NOCOMMWARNTIME 300 # extended timeframe, you can use this throttle to reduce the stress on # syslog traffic and storage, by posting these messages only once in every # several loop cycles, and when the error condition has changed or cleared. -# A negative value means standard behavior, and a zero value means to never -# repeat the message (log only on start and end/change of the failure state). +# A negative value means standard behavior (log on every loop), and a zero +# value means to never repeat the message (log only on start and end/change +# of the failure state). # #POLLFAIL_LOG_THROTTLE_MAX 100 diff --git a/docs/man/upsmon.conf.txt b/docs/man/upsmon.conf.txt index 6f559092be..4b85a8485f 100644 --- a/docs/man/upsmon.conf.txt +++ b/docs/man/upsmon.conf.txt @@ -171,9 +171,10 @@ system log as configured. If your devices are expected to be AWOL for an extended timeframe, you can use this throttle to reduce the stress on syslog traffic and storage, by posting these messages only once in every several loop cycles, and when the error condition has changed or cleared. - -A negative value means standard behavior, and a zero value means to never -repeat the message (log only on start and end/change of the failure state). ++ +A negative value means standard behavior (log on every loop), and a zero +value means to never repeat the message (log only on start and end/change +of the failure state). *NOTIFYCMD* 'command':: diff --git a/docs/man/upsmon.txt b/docs/man/upsmon.txt index 227d9c34c7..bc3adf05ef 100644 --- a/docs/man/upsmon.txt +++ b/docs/man/upsmon.txt @@ -475,9 +475,9 @@ system log as configured. If your devices are expected to be AWOL for an extended timeframe, you can use POLLFAIL_LOG_THROTTLE_MAX to reduce the stress on syslog traffic and storage, by posting these messages only once in every several loop cycles, and when the error condition has changed or -cleared. A negative value means standard behavior, and a zero value means -to never repeat the message (log only on start and end/change of the failure -state). +cleared. A negative value means standard behavior (log on every loop), +and a zero value means to never repeat the message (log only on start and +end/change of the failure state). RELOADING NUANCES ----------------- From f1cfa4c52dcf024e45f7c73a3e54d94b37972b27 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 11:28:17 +0100 Subject: [PATCH 12/20] clients/upsmon.c: clarify wording about POLLFAIL_LOG_THROTTLE_MAX "standard behavior" Signed-off-by: Jim Klimov --- clients/upsmon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/upsmon.c b/clients/upsmon.c index 01aa2604f7..d266a61e53 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -60,8 +60,8 @@ static unsigned int pollfreq = 5, pollfreqalert = 5; * will only be repeated every so many POLLFREQ loops. * If pollfail_log_throttle_max == 0, such error messages will * only be reported once when that situation starts, and ends. - * By default it is logged every pollfreq (which can abuse syslog - * and its storage). + * By default (or for negative values) it is logged every pollfreq + * loop cycle (which can abuse syslog and its storage). * To support this, each utype_t (UPS) structure tracks individual * pollfail_log_throttle_count and pollfail_log_throttle_state */ From 0d26c4536222e8893f43794adf73f6dca4a3a6ed Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 11:39:42 +0100 Subject: [PATCH 13/20] clients/upsmon.c, NEWS.adoc: Forget POLLFAIL_LOG_THROTTLE_MAX before configuration reload [#2207] Signed-off-by: Jim Klimov --- NEWS.adoc | 4 ++++ clients/upsmon.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/NEWS.adoc b/NEWS.adoc index d205e9b90d..a18389492e 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -55,6 +55,10 @@ https://github.com/networkupstools/nut/milestone/10 activity was completed by the hardware, which led to mis-processing of shutdown triggers. Also, notification was added to report "finished calibration". [issue #2168, PR #2169] + * `upsmon` support for `POLLFAIL_LOG_THROTTLE_MAX` did not neuter the + applied setting when live-reloading configuration, so commenting it + away in `upsmon.conf` did not have the effect of resetting the logging + frequency to default. [#2207] * Drivers running with non-default user account (e.g. with `user=root` in their configuration) failed to apply group ownership and permissions to their Unix socket file for interaction with the local data server. diff --git a/clients/upsmon.c b/clients/upsmon.c index d266a61e53..af1e2997b6 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -3,6 +3,7 @@ Copyright (C) 1998 Russell Kroll 2012 Arnaud Quette + 2020-2023 Jim Klimov This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1867,6 +1868,13 @@ static void loadconfig(void) * (or commented away) the debug_min * setting, detect that */ nut_debug_level_global = -1; + + if (pollfail_log_throttle_max >= 0) { + upslogx(LOG_INFO, + "Forgetting pollfail_log_throttle_max=%d before configuration reload", + pollfail_log_throttle_max); + pollfail_log_throttle_max = -1; + } } while (pconf_file_next(&ctx)) { From 5b912d4315d1d3a73ac9013a606e747a6affc6a5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 11:45:32 +0100 Subject: [PATCH 14/20] clients/upsmon.c, NEWS.adoc: fix an off-by-one error with POLLFAIL_LOG_THROTTLE_MAX loop counting [#2207] Signed-off-by: Jim Klimov --- NEWS.adoc | 3 +++ clients/upsmon.c | 11 +++++++---- conf/upsmon.conf.sample.in | 8 +++++--- docs/man/upsmon.conf.txt | 9 ++++++--- docs/man/upsmon.txt | 9 ++++++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index a18389492e..bb0b2b522e 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -59,6 +59,9 @@ https://github.com/networkupstools/nut/milestone/10 applied setting when live-reloading configuration, so commenting it away in `upsmon.conf` did not have the effect of resetting the logging frequency to default. [#2207] + * `upsmon` support for `POLLFAIL_LOG_THROTTLE_MAX` had an off-by-one error + (e.g. reporting "Data stale" or "Driver not connected" every 30 sec with + `POLLFAIL_LOG_THROTTLE_MAX 5` and `POLLFREQ 5` settings). [#2207] * Drivers running with non-default user account (e.g. with `user=root` in their configuration) failed to apply group ownership and permissions to their Unix socket file for interaction with the local data server. diff --git a/clients/upsmon.c b/clients/upsmon.c index af1e2997b6..586a59c9dc 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -62,7 +62,8 @@ static unsigned int pollfreq = 5, pollfreqalert = 5; * If pollfail_log_throttle_max == 0, such error messages will * only be reported once when that situation starts, and ends. * By default (or for negative values) it is logged every pollfreq - * loop cycle (which can abuse syslog and its storage). + * loop cycle (which can abuse syslog and its storage), same as + * if "max = 1". * To support this, each utype_t (UPS) structure tracks individual * pollfail_log_throttle_count and pollfail_log_throttle_state */ @@ -2267,9 +2268,11 @@ static void pollups(utype_t *ups) * failure state */ pollfail_log = 0; } else { - /* Only log once for start, every MAX iterations, - * and end of the same failure state */ - if (ups->pollfail_log_throttle_count++ >= pollfail_log_throttle_max) { + /* here (pollfail_log_throttle_max > 0) : + * only log once for start, every MAX iterations, + * and end of the same failure state + */ + if (ups->pollfail_log_throttle_count++ >= (pollfail_log_throttle_max - 1)) { /* ping... */ pollfail_log = 1; ups->pollfail_log_throttle_count = 0; diff --git a/conf/upsmon.conf.sample.in b/conf/upsmon.conf.sample.in index cafa7448b8..8634f5d540 100644 --- a/conf/upsmon.conf.sample.in +++ b/conf/upsmon.conf.sample.in @@ -415,9 +415,11 @@ NOCOMMWARNTIME 300 # extended timeframe, you can use this throttle to reduce the stress on # syslog traffic and storage, by posting these messages only once in every # several loop cycles, and when the error condition has changed or cleared. -# A negative value means standard behavior (log on every loop), and a zero -# value means to never repeat the message (log only on start and end/change -# of the failure state). +# A negative value means standard behavior (log on every loop, same as when +# max=1), and a zero value means to never repeat the message (log only on +# start and end/change of the failure state). +# Note that this throttle only applies to one latest-active error state per +# monitored device. # #POLLFAIL_LOG_THROTTLE_MAX 100 diff --git a/docs/man/upsmon.conf.txt b/docs/man/upsmon.conf.txt index 4b85a8485f..0a1a49b660 100644 --- a/docs/man/upsmon.conf.txt +++ b/docs/man/upsmon.conf.txt @@ -172,9 +172,12 @@ extended timeframe, you can use this throttle to reduce the stress on syslog traffic and storage, by posting these messages only once in every several loop cycles, and when the error condition has changed or cleared. + -A negative value means standard behavior (log on every loop), and a zero -value means to never repeat the message (log only on start and end/change -of the failure state). +A negative value means standard behavior (log on every loop, effectively +same as when `max=1`), and a zero value means to never repeat the message +(log only on start and end/change of the failure state). ++ +Note that this throttle only applies to one latest-active error state per +monitored device. *NOTIFYCMD* 'command':: diff --git a/docs/man/upsmon.txt b/docs/man/upsmon.txt index bc3adf05ef..ad751603ee 100644 --- a/docs/man/upsmon.txt +++ b/docs/man/upsmon.txt @@ -475,9 +475,12 @@ system log as configured. If your devices are expected to be AWOL for an extended timeframe, you can use POLLFAIL_LOG_THROTTLE_MAX to reduce the stress on syslog traffic and storage, by posting these messages only once in every several loop cycles, and when the error condition has changed or -cleared. A negative value means standard behavior (log on every loop), -and a zero value means to never repeat the message (log only on start and -end/change of the failure state). +cleared. A negative value means standard behavior (log on every loop, +effectively same as when `max=1`), and a zero value means to never repeat +the message (log only on start and end/change of the failure state). + +Note that this throttle only applies to one latest-active error state per +monitored device. RELOADING NUANCES ----------------- From 1ada79e2201dbf08b909a7a29f5f2df768ca82fd Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 12:09:10 +0100 Subject: [PATCH 15/20] clients/upsmon.c: markup/style typo fix Signed-off-by: Jim Klimov --- clients/upsmon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clients/upsmon.c b/clients/upsmon.c index 586a59c9dc..b739ce9d4f 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -218,7 +218,8 @@ typedef struct async_notify_s { int flags; char *ntype; char *upsname; - char *date; } async_notify_t; + char *date; +} async_notify_t; static unsigned __stdcall async_notify(LPVOID param) { From 2ca6e84357e4843f674357f28672b5f7c7bf7557 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 12:09:47 +0100 Subject: [PATCH 16/20] clients/upsmon.c: forget poll-failure error-states and the counts involved when we reload config [#2207] Signed-off-by: Jim Klimov --- NEWS.adoc | 3 ++- clients/upsmon.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index bb0b2b522e..6ff7edbfc6 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -58,7 +58,8 @@ https://github.com/networkupstools/nut/milestone/10 * `upsmon` support for `POLLFAIL_LOG_THROTTLE_MAX` did not neuter the applied setting when live-reloading configuration, so commenting it away in `upsmon.conf` did not have the effect of resetting the logging - frequency to default. [#2207] + frequency to default. It also did not reset the counters to certainly + follow the new configuration for existing faults. [#2207] * `upsmon` support for `POLLFAIL_LOG_THROTTLE_MAX` had an off-by-one error (e.g. reporting "Data stale" or "Driver not connected" every 30 sec with `POLLFAIL_LOG_THROTTLE_MAX 5` and `POLLFREQ 5` settings). [#2207] diff --git a/clients/upsmon.c b/clients/upsmon.c index b739ce9d4f..96e08461b1 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -1872,10 +1872,24 @@ static void loadconfig(void) nut_debug_level_global = -1; if (pollfail_log_throttle_max >= 0) { + utype_t *ups; + upslogx(LOG_INFO, - "Forgetting pollfail_log_throttle_max=%d before configuration reload", + "Forgetting pollfail_log_throttle_max=%d and " + "resetting UPS error-state counters before " + "a configuration reload", pollfail_log_throttle_max); pollfail_log_throttle_max = -1; + + /* forget poll-failure logging throttling, so that we + * rediscover the error-states and the counts involved + */ + ups = firstups; + while (ups) { + ups->pollfail_log_throttle_count = -1; + ups->pollfail_log_throttle_state = UPSCLI_ERR_NONE; + ups = ups->next; + } } } From 61cbb0ac569023578a59f38a2a94333053378f14 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 12:17:03 +0100 Subject: [PATCH 17/20] clients/upsmon.c: align logged POLLFAIL_LOG_THROTTLE_MAX casing with the setting/docs Signed-off-by: Jim Klimov --- clients/upsmon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/upsmon.c b/clients/upsmon.c index 96e08461b1..937b992a8a 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -1875,7 +1875,7 @@ static void loadconfig(void) utype_t *ups; upslogx(LOG_INFO, - "Forgetting pollfail_log_throttle_max=%d and " + "Forgetting POLLFAIL_LOG_THROTTLE_MAX=%d and " "resetting UPS error-state counters before " "a configuration reload", pollfail_log_throttle_max); @@ -1938,7 +1938,7 @@ static void loadconfig(void) if (pollfail_log_throttle_max >= 0) { upslogx(LOG_INFO, - "Applying pollfail_log_throttle_max=%d from upsmon.conf", + "Applying POLLFAIL_LOG_THROTTLE_MAX %d from upsmon.conf", pollfail_log_throttle_max); } } From 85ce92358697352f0935e72878af871038612829 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 12:17:51 +0100 Subject: [PATCH 18/20] clients/upsmon.c: when POLLFAIL_LOG_THROTTLE_MAX>0 takes effect, report also how often it would report in seconds [#2207] Signed-off-by: Jim Klimov --- clients/upsmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clients/upsmon.c b/clients/upsmon.c index 937b992a8a..8b8a573114 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -2308,9 +2308,10 @@ static void pollups(utype_t *ups) upslogx(LOG_ERR, "Poll UPS [%s] failure state code " "changed from %d to %d; " "report below will only be repeated to syslog " - "every %d polling loop cycles:", + "every %d polling loop cycles (%d sec):", ups->sys, ups->pollfail_log_throttle_state, - upserror, pollfail_log_throttle_max); + upserror, pollfail_log_throttle_max, + pollfail_log_throttle_max * pollfreq); } ups->pollfail_log_throttle_state = upserror; From f5cdaf906584689cda12d14dded7c49fb6afe0f1 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 12:23:07 +0100 Subject: [PATCH 19/20] server/conf.c, clients/upsmon.c: align logged DEBUG_MIN NUM casing and wording with the setting/docs Signed-off-by: Jim Klimov --- clients/upsmon.c | 2 +- server/conf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/upsmon.c b/clients/upsmon.c index 8b8a573114..827d2f1d0e 100644 --- a/clients/upsmon.c +++ b/clients/upsmon.c @@ -1924,7 +1924,7 @@ static void loadconfig(void) if (reload_flag == 1) { if (nut_debug_level_global > -1) { upslogx(LOG_INFO, - "Applying debug_min=%d from upsmon.conf", + "Applying DEBUG_MIN %d from upsmon.conf", nut_debug_level_global); nut_debug_level = nut_debug_level_global; } else { diff --git a/server/conf.c b/server/conf.c index c752ed55ca..dd908ce4c8 100644 --- a/server/conf.c +++ b/server/conf.c @@ -415,7 +415,7 @@ void load_upsdconf(int reloading) if (reloading) { if (nut_debug_level_global > -1) { upslogx(LOG_INFO, - "Applying debug_min=%d from upsd.conf", + "Applying DEBUG_MIN %d from upsd.conf", nut_debug_level_global); nut_debug_level = nut_debug_level_global; } else { From 0ea95a7604c7c42924729af0c38fc6733b906bba Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Fri, 1 Dec 2023 13:56:35 +0100 Subject: [PATCH 20/20] data/driver.list.in: note that "NEW Keor Multiplug" is not supported as of 2023 ...per "mrc989" report on IRC channel Signed-off-by: Jim Klimov --- data/driver.list.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/driver.list.in b/data/driver.list.in index 1bb1bee82d..9c74f758bd 100644 --- a/data/driver.list.in +++ b/data/driver.list.in @@ -607,7 +607,7 @@ "Legrand" "ups" "2" "Keor Line RT" "Serial" "nutdrv_qx" "Legrand" "ups" "2" "Keor Line RT" "USB" "nutdrv_qx" "Legrand" "ups" "2" "Keor LP" "Serial" "nutdrv_qx" -"Legrand" "ups" "2" "Keor Multiplug" "USB" "nutdrv_qx" +"Legrand" "ups" "2" "Keor Multiplug" "USB" "nutdrv_qx" # NOTE: As of 2023 reports, the "NEW Keor Multiplug" is not supported (also by older vendor SW) "Legrand" "ups" "2" "Keor S" "Serial" "nutdrv_qx" "Legrand" "ups" "2" "Keor S" "USB" "nutdrv_qx" "Legrand" "ups" "3" "Keor PDU" "USB" "usbhid-ups"