Question

Cannot decode json response: malformed UTF-8 character in JSON string

  • 16 May 2024
  • 1 reply
  • 36 views

Badge +3

Hello,

I have an encoding problem for Windows update supervision. French server
The plugin works locally, but not from the Centreon server.

mode=Update
Centreon Plugins Release 20240325

Centreon Server 24.04

 

From server locally

C:\Program Files\Centreon NSClient++\scripts\centreon>centreon_plugins.exe --plugin=os::windows::local::plugin --mode=updates --verbose --display-updates --source-encoding=ISO-8859-1
OK: pending Windows updates: 1 | 'windows.pending.updates.count'=1;;;0;
update: 2024-05 Mise à jour cumulative pour Windows Server 2019 pour les systèmes x64 (KB5037765) [mandatory: no]

C:\Program Files\Centreon NSClient++\scripts\centreon>

From Centreon Server

/usr/lib/centreon/plugins/centreon_nsclient_restapi.pl --plugin=apps::nsclient::restapi::plugin --mode=query --hostname='IP' --port='8444' --proto='https' --legacy-password='centreon' --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE" --timeout=30 --command=check_centreon_plugins --arg='os::windows::local::plugin' --arg='updates' --arg='--filter-title="" --exclude-title="" --filter-mandatory="" --warning-pending-updates="" --critical-pending-updates="" --verbose --display-updates --source-encoding=ISO-8859-1 '

UNKNOWN: Cannot decode json response: malformed UTF-8 character in JSON string, at character offset 191 (before "\x{fffd}0080\x{fffd}...") at /usr/lib/centreon/plugins/centreon_nsclient_restapi.pl line 165.

Thanks for help.


1 reply

Badge +3

/usr/lib/centreon/plugins/centreon_nsclient_restapi.pl  

Line ~ 162

sub check_nscp_result {
my ($self, %options) = @_;

my $encoded_content = encode('UTF-8', $options{content});
my $decoded;
eval {
$decoded = decode_json($encoded_content);
#$decoded = decode_json($options{content});

};

not bad but bad =)

usr/lib/centreon/plugins/centreon_nsclient_restapi.pl --plugin=apps::nsclient::restapi::plugin --mode=query --hostname='IP' --port='8444' --proto='https' --legacy-password='centreon' --source-encoding=ISO-8859-1 --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE" --timeout=30 --command=check_centreon_plugins --arg='os::windows::local::plugin' --arg='updates' --arg='--filter-title="" --exclude-title="" --filter-mandatory="" --warning-pending-updates="" --critical-pending-updates="" --verbose --display-updates --source-encoding=ISO-8859-1 '

OK: pending Windows updates: 1 | 'windows.pending.updates.count'=1;;;0;
update: 2024-05 Mise … jour cumulative pour Windows Server 2019 pour les systŠmes x64 (KB5037765) [mandatory: no]

 

Reply