centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
309 stars 271 forks source link

[os::windows::wsman::plugin] --mode=pending-reboot: UNKNOWN: Cannot decode json response #4599

Open joschi99 opened 11 months ago

joschi99 commented 11 months ago

Latest plugin version:

-bash-4.2$ ./centreon_plugins.pl --hostname=x.x.x.x --wsman-port=5986 --wsman-path='/wsman' --wsman-username=administrator --wsman-password='xxx' --wsman-scheme=https --wsman-timeout=30 --wsman-auth-method=basic --plugin=os::windows::wsman::plugin --mode=pending-reboot --debug
UNKNOWN: Cannot decode json response: malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "PowerShell[.exe] [-P...") at /tmp/joschi/centreon-plugins-develop/src/os/windows/wsman/mode/pendingreboot.pm line 110.

I have started manually the PS code on the host and this seem's working: image

garnier-quentin commented 11 months ago

It's the same issue i think: https://github.com/centreon/centreon-plugins/issues/4461 Could you check the file transferred on the windows and decode it ?

joschi99 commented 11 months ago

seems working: image

here you can find the file pendingreboot-7B615C18.bat.txt

garnier-quentin commented 11 months ago

With --debug you have the same error (like the other ticket) ?

joschi99 commented 11 months ago

I have launched the command with --debug and another time with --debug-stream, but I can encode the file correctly

thezipman commented 7 months ago

As explained in the issue 4461 (https://github.com/centreon/centreon-plugins/issues/4461) the problem appears to be related to the use of cmd.exe to execute the script file. CMD has a limit of 8191 characters for a single command, but the .bat file is bigger. This is the reason it works when pasted in powershell (which has a command line length limit of 64k) but it doesn't work if pasted in a CMD shell.