Solved

os::windows::local::plugin - Error while requesting Updates


Userlevel 1
Badge +3

Hello !

I’m trying to get the number and the listing of updates available on my windows server. When there are none, the result is good, but when there are some I have a backslash error.

Here is the command :

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H server1.domain.local -p 5666 -t 30 -u -2 -P 8192 -c check_centreon_plugins -a 'os::windows::local::plugin' 'updates' ' --filter-title="" --exclude-title="" --filter-mandatory="" --warning-pending-updates="" --critical-pending-updates=""  --verbose --display-updates '

return the following error :

UNKNOWN: Cannot decode json response: illegal backslash escape sequence in string, at character offset 44 (before "\\x85 jour cumulativ...") at C:\Windows\TEMP\par-53525653514c3230313924\cache-c0092cafd5f6f1c92999240ce6556f3a3bb56530\inc\lib/os/windows/local/mode/updates.pm line 107.

My plugin version is normaly the latest available : centreon_plugins_20221710_x64.exe.

Thank’s for any help.

icon

Best answer by Jumulus 9 May 2023, 17:08

View original

10 replies

Userlevel 4
Badge +13

👋

 

@cedricludovic can you try with:

 

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H server1.domain.local -p 5666 -t 60 -u -2 -P 8192 -c check_centreon_plugins -a 'os::windows::local::plugin' 'updates'


/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H server1.domain.local -p 5666 -t 60 -u -2 -P 8192 -c check_centreon_plugins -a 'os::windows::local::plugin' 'updates' ' --verbose --display-updates '

Also, any clues in your nsclient.log?

Userlevel 1
Badge +3

Hello,

 

Thank’s for your help.

Unfortunately, no clues in nsclient.log, even in debug or trace mode.

The last line is the command I do.

 

The 2 commands gave the same result :

 

UNKNOWN: Cannot decode json response: illegal backslash escape sequence in string, at character offset 44 (before "\\x85 jour cumulativ...") at C:\Windows\TEMP\par-53525653514c3230313924\cache-c0092cafd5f6f1c92999240ce6556f3a3bb56530\inc\lib/os/windows/local/mode/updates.pm line 107.

 

 

 

Userlevel 4
Badge +13

we can check that nrpe3 is working ok, update x.x.x.x with the required host.

 time /usr/lib64/nagios/plugins/check_centreon_nrpe3 -H x.x.x.x -p 5666 -t 600 -u -2 -P 8192

then confirm that you have the latest plugin

https://github.com/centreon/centreon-nsclient-build/releases

 

 

Userlevel 5
Badge +14

Cannot decode json response: illegal backslash escape sequence in string, at character offset 44 (before "\\x85 jour cumulativ...")

I”ve seen this a lot : there is an issue with french accent and other unicode character in the centreon plugins for windows

“Mise à jour cumulative” (the name of the patch in french) contains “à”, this is unicode

 

this problem happens on a lot of check, I have some issues with german and french servers, even on service names where the check return json decode errors

it also happen with the check nscllient web api or nrpe, but as the message states, it’s the perl file on windows side that does the error, not the check on the poller side

(you can have the problem on some exchange check for  queues, for windows services with unicode, usually third party apps or in house development where they used é è ç à… )

 

I never deep dived in this part of the code, and found workarounds (exclusion, or simply ignoring), but maybe something could be done globally on the windows plugins to parse all string for unicode char before converting them in json, or maybe there are option in the perl json lib to work around that.

It is way too complicated for me to debug

Userlevel 4
Badge +13

https://docs.centreon.com/pp/integrations/plugin-packs/procedures/operatingsystems-windows-nsclient-05-restapi/#unknown-cannot-decode-json-response-malformed-utf-8-character-in-json-string

 

could help

Userlevel 5
Badge +14

ah yes, this, but that’s not what  I was mentionning, there are some issue also sometime in the “windows\temp….pm” code generated by the plugin pack windows that uses json and have the decoding issue on top of the restapi issue

this is what’s happening in cedricludovic’s case

this perl https://github.com/centreon/centreon-plugins/blob/c642befb68297d4cd516c9532b9518d2bebd2d7a/src/os/windows/local/mode/updates.pm#L107

parse the json output from this powershell command output centreon-plugins/updates.pm at develop · centreon/centreon-plugins · GitHub

you can see some encoding/escaping in this last script, but that’s where I lost my way trying to understand which string escaping was taking place where

 

any scripts in this folder centreon-plugins/src/centreon/common/powershell at develop · centreon/centreon-plugins · GitHub using json output from poweshell from perl can have issue with unicode char, it’s hard to debug

Userlevel 1
Badge +3

@christophe.niel-ACT Your right. It’s exactly the problem. It’s an issue with the french accent.

And this is far beyond my knowledge.

Userlevel 2
Badge +5

Pour les accents: 

 

 --source-encoding=ISO-8859-1

 

La solution n’est pas de moi mais ça marche:

 

/usr/lib64/nagios/plugins/check_centreon_nrpe -H RDSH03 -p 5666 -t 420 -u -m 8192 -c check_centreon_plugins -a 'os::windows::local::plugin' 'updates' ' --filter-title="" --exclude-title="Microsoft Defender Antivirus" --filter-mandatory="" --warning-pending-updates="0" --critical-pending-updates="2"  --exclude-title="KB5023049" --verbose --display-updates --source-encoding=ISO-8859-1 '

Userlevel 1
Badge +3

Thank you Jumulus,

It works like a charm.

Userlevel 5
Badge +14

oh nice information

Reply