Skip to content

Commit

Permalink
Prevent log spam with nut plugins
Browse files Browse the repository at this point in the history
On Debian / Ubuntu, nut is linked against libnss3 which causes a warning
message to be emitted when upsc is run if SSL isn't being used. This
leads to errors during every poll like:

2024/09/04-21:05:07 [299208] Error output from nut_misc:
2024/09/04-21:05:07 [299208]         Init SSL without certificate database

nut 2.8.1, which has started making its way to distros, adds a new
NUT_QUIET_INIT_SSL environment variable (specifically designed for uses
such as this) which allows silencing this warning.

Add it to the nut plugins. It's a no-op for older nut versions.
  • Loading branch information
tofurky committed Sep 5, 2024
1 parent 2175fe6 commit 7a2b7de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/node.d/nut_misc.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ if ( defined $ARGV[0] and $ARGV[0] eq 'config' ) {
}

sub fetch_values {
local $ENV{NUT_QUIET_INIT_SSL} = 1;

my $data = `$config{upsc} $config{upsname}`;
while ($data =~ /([a-z.]+): (.+)\b/g) {
my $label = $1;
Expand Down
2 changes: 2 additions & 0 deletions plugins/node.d/nut_volts.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ if ( defined $ARGV[0] and $ARGV[0] eq 'config' ) {
}

sub fetch_values {
local $ENV{NUT_QUIET_INIT_SSL} = 1;

my $data = `$config{upsc} $config{upsname}`;
while ($data =~ /([a-z.]+): (.+)\b/g) {
my $label = $1;
Expand Down
1 change: 1 addition & 0 deletions plugins/node.d/nutups_.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
UPS=$(basename "$0" | cut -d_ -f2)
FUNCTION=$(basename "$0" | cut -d_ -f3)
UPSC=$(command -v upsc)
export NUT_QUIET_INIT_SSL=1

if [ "$1" = "autoconf" ]; then
[ -x "$UPSC" ] && [ -r /etc/nut/ups.conf ] && echo yes && exit 0
Expand Down

0 comments on commit 7a2b7de

Please sign in to comment.