Solved

nrpe: Command completed with return code 1 and output:

  • 28 July 2023
  • 2 replies
  • 219 views

Userlevel 1
Badge +5

Hello,

maybe someone can help with this. I have a python script from a client that is run by a bash script (which creates the necessary env variables for the python script to work).

 

When run from the host itself, with user nagios, the output is displayed correctly:

nagios@host:~> /var/lib/monitor_ub/custom_plugins/hx_metrics_wrapper.sh iops read 10000 60000
Ok: iops_read ha respost en 0.17 | iops_read=12618.3;10000.0;60000.0
nagios@host:~>

 

But when called from the poller, unable to read output:

-bash-4.2$ /usr/lib64/nagios/plugins/check_nrpe -H xxx.xxx.xxx.xxx -t 30 -c check_latency -a "iops read 10000 60000"
NRPE: Unable to read output
-bash-4.2

 

NRPE show this for the command ran from the poller:

nrpe[28532]: Command completed with return code 1 and output:
nrpe[28532]: Return Code: 3, Output: NRPE: Unable to read output
nrpe[28532]: Connection from xxx.xxx.xxx.xxx closed.

 

As a workaround for now I have set a cron job for each option available for the python script that saves the output to a file and defined commands that read those files and generates the corresponding exit code. NRPE passes that output and the exit code correctly to the poller.

 

I have checked permissions and paths but can’t see what is wrong. Could it be a problem with encoding in the python script?

Regards,

Enrique

icon

Best answer by omercier 30 August 2023, 14:03

View original

2 replies

Userlevel 4
Badge +12

Hi @emeck 

Can you add this at the beginning of your shell script ? It will give your the trace of the commands executed by your script.

exec 2>/var/log/nagios/my.log
set -x

You may have to customize the path. Make sure the directory exists and your nrpe user (presumably nagios) is allowed to write in it.

Do not use /tmp as directory since default builds of nrpe are using a chrooted /tmp.

Userlevel 1
Badge +5

@omercier 

Hello,

thanks for the tip. With the error log saved as suggested, the problem was found. The python script was trying to sav a log file but it didn’t specified the path, just the filename. So it failed to save it in “/logname.log”.

The script provider has modified it to use a path were the nagios user has write permission and it now works as expected.

Thanks again!

Regards.

Reply