-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into armac-2023
- Loading branch information
Showing
12 changed files
with
142 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
Copyright (C) | ||
1998 Russell Kroll <[email protected]> | ||
2012 Arnaud Quette <arnaud.quette.free.fr> | ||
2020-2023 Jim Klimov <[email protected]> | ||
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 | ||
|
@@ -60,8 +61,9 @@ 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), same as | ||
* if "max = 1". | ||
* To support this, each utype_t (UPS) structure tracks individual | ||
* pollfail_log_throttle_count and pollfail_log_throttle_state | ||
*/ | ||
|
@@ -216,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) | ||
{ | ||
|
@@ -1867,6 +1870,27 @@ static void loadconfig(void) | |
* (or commented away) the debug_min | ||
* setting, detect that */ | ||
nut_debug_level_global = -1; | ||
|
||
if (pollfail_log_throttle_max >= 0) { | ||
utype_t *ups; | ||
|
||
upslogx(LOG_INFO, | ||
"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; | ||
} | ||
} | ||
} | ||
|
||
while (pconf_file_next(&ctx)) { | ||
|
@@ -1900,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 { | ||
|
@@ -1914,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); | ||
} | ||
} | ||
|
@@ -2259,9 +2283,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; | ||
|
@@ -2282,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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
# a single simple call. | ||
# | ||
# Copyright (C): | ||
# 2022 Jim Klimov <[email protected]> | ||
# 2022-2023 Jim Klimov <[email protected]> | ||
# | ||
# License: GPLv2+ | ||
|
||
|
@@ -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" ] \ | ||
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters