Returned an invalid return code: 255

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
raamardhani7
Posts: 459
Joined: Tue Jun 02, 2015 12:36 am

Returned an invalid return code: 255

Post by raamardhani7 »

Hello,

I am trying to check the CPU usage through NRPE check on a Windows server using custom script which is deployed on remote host.

When tried to execute the script locally on the windows server we are getting the expected output but in Nagios this service check is throwing error.
Already tried to restart the NS client and execution policy is set to unrestricted, but not getting the output.

Command executed from Nagios server:
/usr/local/nagios/libexec/check_nrpe -H [remote host IP] -t 30 -c cpu 80

Below entry is made in NS Client Configuration file, where CPU_Memory_Process.ps1 is the custom script :
cpu = cmd /c echo scripts\CPU_Memory_Process.ps1; exit($lastexitcode) | powershell.exe -command -

The result on Nagios is:
The command (cpu) returned an invalid return code: 255

Expected result:
Transcript started, output file is C:\CPU_logs\transcript.log

NOTE: The same script is working on other servers but only on few servers it is throwing error.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Returned an invalid return code: 255

Post by npolovenko »

Hello, @raamardhani7. Can you put another backslash after `scripts` to see if that helps:

Code: Select all

cpu = cmd /c echo scripts\\CPU_Memory_Process.ps1; exit($lastexitcode) | powershell.exe -command -
Can you upload the script to this forum? That way I could test it on my server and be able to faster figure out what's wrong. Also, I'd like to see the nsclient.ini config file from your windows server. You may need to have some security options enabled in there.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked