Skip to content

Commit

Permalink
Prevent log spam with nut plugins (#1631)
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
kenyon authored Sep 5, 2024
2 parents 3327507 + c8824ad commit fa433a4
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
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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
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_
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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 fa433a4

Please sign in to comment.