Nscp-api cannot parse json response body

On several Windows servers, I’m receiving outputs where the error message is: “UNKNOWN - Cannot parse JSON response body”.

More strangely, when I query for “check_cpu”, sometime I get the correct output and sometime I get the “UNKNOWN” error message.

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
UNKNOWN - Cannot parse JSON response body '{"header":{"source_id":""},"payload":[{"command":"check_cpu","lines":[{"message":"OK: CPU load is ok.","perf":[{"alias":"total 5m","int_value":{"critical":90,"unit":"%","value":3,"warning":80}},{"alias":"total 1m","int_value":{"critical":90,"unit":"%","value":2,"warning":80}},{"alias":"total 5s","int_value":{"critical":90,"unit":"%","value":4,"warning":80}}]}],"result":"OK"}]}disk_', error: [json.exception.parse_error.101] parse error at line 1, column 380: syntax error while parsing value - invalid literal; last read: '"OK"}]}d'; expected end of input
C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
UNKNOWN - Cannot parse JSON response body '{"header":{"source_id":""},"payload":[{"command":"check_cpu","lines":[{"message":"OK: CPU load is ok.","perf":[{"alias":"total 5m","int_value":{"critical":90,"unit":"%","value":3,"warning":80}},{"alias":"total 1m","int_value":{"critical":90,"unit":"%","value":3,"warning":80}},{"alias":"total 5s","int_value":{"critical":90,"unit":"%","value":4,"warning":80}}]}],"result":"OK"}]}D', error: [json.exception.parse_error.101] parse error at line 1, column 380: syntax error while parsing value - invalid literal; last read: '"OK"}]}D'; expected end of input
C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
UNKNOWN - Cannot parse JSON response body '{"header":{"source_id":""},"payload":[{"command":"check_cpu","lines":[{"message":"OK: CPU load is ok.","perf":[{"alias":"total 5m","int_value":{"critical":90,"unit":"%","value":4,"warning":80}},{"alias":"total 1m","int_value":{"critical":90,"unit":"%","value":7,"warning":80}},{"alias":"total 5s","int_value":{"critical":90,"unit":"%","value":3,"warning":80}}]}],"result":"OK"}]}D', error: [json.exception.parse_error.101] parse error at line 1, column 380: syntax error while parsing value - invalid literal; last read: '"OK"}]}D'; expected end of input
C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
check_cpu OK: CPU load is ok. | 'total 5m'=4%;80;90 'total 1m'=7%;80;90 'total 5s'=3%;80;90

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
check_cpu OK: CPU load is ok. | 'total 5m'=4%;80;90 'total 1m'=8%;80;90 'total 5s'=2%;80;90

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
check_cpu OK: CPU load is ok. | 'total 5m'=4%;80;90 'total 1m'=8%;80;90 'total 5s'=5%;80;90

Other queries, I consistently get the “UNKNOWN” error message. Examples:

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_pagesize
UNKNOWN - Cannot parse JSON response body '{"payload":[{"command":"check_pagesize","lines":[{"message":"Unknown command(s): check_pagesize"}],"result":"UNKNOWN"}]}total*1Ç≤h@MBfffz@!ÇÖÖÖü@19å@;', error: [json.exception.parse_error.101] parse error at line 1, column 122: syntax error while parsing value - invalid literal; last read: '"UNKNOWN"}]}to'; expected end of input
C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_memory
UNKNOWN - Cannot parse JSON response body '{"header":{"source_id":""},"payload":[{"command":"check_memory","lines":[{"message":"OK: committed = 2.577GB, physical = 2.431GB","perf":[{"alias":"committed","float_value":{"critical":4.2183002466335893,"maximum":4.6870002746582031,"minimum":0.00000000000000000,"unit":"GB","value":2.5772323608398438,"warning":3.7496002195402980}},{"alias":"committed %","float_value":{"critical":90', error: [json.exception.parse_error.101] parse error at line 1, column 385: syntax error while parsing object - unexpected end of input; expected '}'
C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_drivesize
UNKNOWN - Cannot parse JSON response body '{"header":{"source_id":""},"payload":[{"command":"check_drivesize","lines":[{"message":"OK All 2 drive(s) are ok","perf":[{"alias":"C:\\ used","float_value":{"critical":53.515719222836196,"maximum":59.461910247802734,"minimum":0.00000000000000000,"unit":"GB","value":17.924423217773438,"warning":47.569528197869658}},{"alias":"C:\\ used %","float_value":{"critical":90.000000000000000', error: [json.exception.parse_error.101] parse error at line 1, column 385: syntax error while parsing object - unexpected end of input; expected '}'

System information

C:\Program Files\ICINGA2\sbin>icinga2.exe -V
icinga2.exe - The Icinga 2 network monitoring daemon (version: v2.11.0-rc1-1-g2b891fd1e)

Copyright (c) 2012-2019 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Windows
  Platform version: 8 (Server)
  Kernel: Windows
  Kernel version: 6.2
  Architecture: x86_64

Build information:
  Compiler: MSVC 19.16.27032.1
  Build host: WINBUILD2

NSClient++ (x64) - Product version: 0.5.2039

nsclient.ini

; in flight - TODO
[/settings/default]

; Undocumented key
password = icinga

; Undocumented key
allowed hosts = 127.0.0.1

; in flight - TODO
[/modules]

; Undocumented key
CheckDisk = enabled

; Undocumented key
WEBServer = enabled

; Undocumented key
CheckSystem = enabled

Interestingly, I checked another Windows server with an older version of Icinga2 (v2.10.5) and it does not have those issues. Is there a bug with the newest agent?

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_cpu
check_cpu OK: CPU load is ok. | 'total 5m'=16%;80;90 'total 1m'=24%;80;90 'total 5s'=8%;80;90

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_memory
check_memory OK: committed = 3.004GB, physical = 2.777GB | 'committed'=3.003582GB;3.749600;4.218300;0;4.687000 'committed %'=64%;80;90;0;100 'physical'=2.777267GB;3.199600;3.599550;0;3.999500 'physical %'=69%;80;90;0;100

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_drivesize
check_drivesize OK All 3 drive(s) are ok | 'D:\ used'=1.918354GB;15.997653;17.997360;0;19.997066 'D:\ used %'=10%;80;90;0;100 'C:\ used'=19.664661GB;47.569528;53.515719;0;59.461910 'C:\ used %'=33%;80;90;0;100 'E:\ used'=0B;0;0;0;0

C:\Program Files\ICINGA2\sbin>check_nscp_api.exe --password icinga -P 8443 -H localhost -q check_pagefile
check_pagefile OK: \??\C:\pagefile.sys 125.609MB (704MB), total 125.609MB (704MB) | '\??\C:\pagefile.sys'=125.609375MB;422.400000;563.200000;0;704 '\??\C:\pagefile.sys %'=18%;60;80;0;100 'total'=125.609375MB;422.400000;563.200000;0;704 'total %'=18%;60;80;0;100

Information about the Icigna2 Agent:

C:\Program Files\ICINGA2\sbin>icinga2.exe -V
icinga2.exe - The Icinga 2 network monitoring daemon (version: v2.10.5)

Copyright (c) 2012-2019 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Windows
  Platform version: 8 (Server)
  Kernel: Windows
  Kernel version: 6.2
  Architecture: x86_64

Build information:
  Compiler: MSVC 19.0.24215.1
  Build host: ICINGA-BUILD-WI

NSClient++ (x64) - Product version: 0.5.0062

I have rolled back the agents to v2.10.5 since there are no issues with the output. For now, I will close this post.

Hopefully, there will be a fix for this in future versions.

Hello @yungd and thank you for reporting!

Please open an issue on GitHub about this.

Best,
AK

Alex was so kind in fixing this, https://github.com/Icinga/icinga2/pull/7447 and I’ve triggered snapshot builds here for you to test then. https://git.icinga.com/packaging/windows-icinga2/pipelines/5025