Hi,
We use the standard centreon Plugin ‘centreon_nsclient_restapi.pl ‘ (From centreon-plugin-Operatingsystems-Windows-Restapi-20230912-083720.el8.noarch)… to run multiple scripts on our remote servers.
One of the script (powershell) reads and reports some log file content …. It is executed on a Windows 2019 serveur (The standard encoding on the powershell is UTF-8).
The log file is a standard .txt file:
If the logs files contains a line like :
“ven. 2023-12-01 10:50:04 ERROR Export_LyncCtrlDeviations Nombre d'erreurs à vérifier”
The result is :
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 162.
The debug mode shows that It receives the string : ‘à vérifier’, like : ▒\u0080▒ v▒\u0080\u009Arifier
If I just remove the accented characters fron the file…. the plugins works well.
“ven. 2023-12-01 10:50:04 ERROR Export_LyncCtrlDeviations Nombre d'erreurs a verifier”
The plugin command line is :
/usr/lib/centreon/plugins/centreon_nsclient_restapi.pl --plugin=apps::nsclient::restapi::plugin --mode=query --ssl-opt="SSL_verify_mode => SSL_VERIFY_NONE" --hostname=myserver --port='5666' --proto='https' --legacy-password='$MYPASSWD' --timeout=15 --command=check_scheduledjoblog --arg="c:/\Log/\Lync/\Export"
What I tried is :
1- To add this option to the plugin :
--source-encoding=UTF-8
OR:
--source-encoding=iso-8859-1
… but the error is always the same
2- Transform the output from the executed script itself (powershell) :
CODE:
$iso = System.Text.Encoding]::GetEncoding("ISO-8859-1")
$utf8 = SSystem.Text.Encoding]::UTF8
$bytes = $utf8.GetBytes($today_output)
$today_output2 = $iso.GetString($bytes)
write-host $today_output2
…. But is doesn’t help ….
Any Idea ??
Thanks a lot