Page 1 of 2

custom plugin: CHECK_NRPE: Receive header underflow - only 0

Posted: Tue Apr 30, 2019 9:32 am
by anilgupta
On target server, I have shell script as attached under /usr/local/nagios/libexec/check_oim which CURL the URL and based on output returns exit code.

on the same server, I have below line added to nrpe.cfg:

Code: Select all

command[check_oim]=/usr/local/nagios/libexec/check_oim
Now when I try to execute the command/plugin from Nagios server with check_nrpe, it throws the error as below:

Code: Select all

[guptaa@cacbigdcapmdw51 libexec]$ /usr/local/nagios/libexec/check_nrpe -H 10.92.34.66 -n -c check_oim
CHECK_NRPE: Receive header underflow - only 0 bytes received (4 expected).

I am looking for your guidance to understand the issue.

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 9:34 am
by anilgupta
Attached is the shell script

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 9:35 am
by anilgupta
The NRPE version on the target server:

Code: Select all

[guptaa@cacbigdcapmdw51 libexec]$ /usr/local/nagios/libexec/check_nrpe -H 10.92.34.66
NRPE v2.13

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 1:46 pm
by benjaminsmith
Hi @anilgupta,

Are you able to run the plugin without the 'do not use ssl' option? If not, what is the error message?

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 10.92.34.66 -c check_oim
Thanks.

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 1:56 pm
by anilgupta
@benjaminsmith
Thanks for your response. I am getting message as below

Code: Select all

[guptaa@cacbigdcapmdw51 ~]$ /usr/local/nagios/libexec/check_nrpe -H 10.92.34.66 -c check_oim
NRPE: Unable to read output

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 2:48 pm
by benjaminsmith
Hi @anilgupta,

Can you log into the server with the script installed and run the plugin and post the output? Is the plugin returning proper output?

Also, please upload the NRPE configuration file ( /usr/local/nagios/etc/nrpe ) for us to review.

Often, this error is the result of incorrect permissions or file paths. Please refer to the troubleshooting guide below.
NRPE - NRPE: Unable To Read Output

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 4:06 pm
by anilgupta
@benjaminsmith,

I do not have access to the server and I rely on operation team.
I will work with them and get the requested information.

Meanwhile, I don't think if this is related to incorrect permission or files. I modified my parameter condition message and it was throwing message as below.

Code: Select all

[guptaa@cacbigdcapmdw51 libexec]$ /usr/local/nagios/libexec/check_nrpe -H 10.92.34.66 -c check_oim hostname nossl
this is issue with parameters:::: first:  .....second:  --------third:
Can you please confirm if I am using check_nrpe correctly to call my custom command?

Secondly, I would like to schedule my day so that I can get longer to time work with you. Please let me know what is your working hours?

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Tue Apr 30, 2019 4:36 pm
by benjaminsmith
Hi @anilgupta,

OK. I'll wait for the other information. Our support hours are as follows ( US Central Time ):

Our normal business hours (Central Time) are listed below:
Monday – Thursday: 9:00 am – 5:00 pm
Friday: 9:00 am – 2:00 pm

I believe you're getting that error message as the script does not recognize the arguments:

Code: Select all

if [ $# -lt 2 ]
then
	echo "this is issue with parameters:::: first: $1 .....second: $2 --------third: $3"
	exit 0
fi
I ran the script as below and it tried to establish an ssh connection.

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Thu May 02, 2019 9:35 am
by anilgupta
@benjaminsmith,
Please find below response to the queries:

Can you log into the server with the script installed and run the plugin and post the output? Is the plugin returning proper output?
From the remote host the script is working fine.

Code: Select all

wassrv@csbtipdcapmdw05 /data/Oracle/Middleware/logs> /usr/local/nagios/libexec/check_oim 10.92.34.66 nossl
Nagios OIM status OK
wassrv@csbtipdcapmdw05 /data/Oracle/Middleware/logs>
please upload the NRPE configuration file ( /usr/local/nagios/etc/nrpe ) for us to review.
Uploading all the files involved. Please ignore the older files as I made few minor changes to the files for troubleshootings.
I believe you're getting that error message as the script does not recognize the arguments:
I think so. The below condition is expecting TWO parameters, even passing these parameters triggering the message. But this is clear that CHECK_NRPE is able to execute the check_oim on remote server.

Code: Select all

if [ $# -lt 2 ]
then
	echo "this is issue with parameters:::: first: $1 .....second: $2 --------third: $3"
	exit 0
fi
Just to test it, I commented out this condition.
and tried the command which is throwing message as below.

Code: Select all

[guptaa@cacbigdcapmdw51 ~]$  /usr/local/nagios/libexec/check_nrpe -H 10.92.34.49 -c check_oim 10.92.34.49, nossl    NRPE: Unable to read output
My understanding says that the command should OIM status message based on value returned for "$status".

Code: Select all

        if [ $status -gt 0 ] 
			then
            nagiosstat=Ok 
			echo "Nagios OIM status OK"	
			exit 0
		else
            nagiosstat=Down 
			echo "Nagios OIM status Down"	
			ssh wassrv@$host tail -100 /data/Oracle/Middleware/user_projects/domains/IAMDomain/servers/oim_server${serverid}/logs/oim_server{$serverid}.log
			
			exit 2
        fi
Please guide if I there is something wrong .

Re: custom plugin: CHECK_NRPE: Receive header underflow - on

Posted: Thu May 02, 2019 11:14 am
by benjaminsmith
Hi @anilgupta,

The issue here is with passing arguments in NRPE. If you want pass arguments to your plugin, enable command argument processing in the NRPE configuration file.

Code: Select all

# COMMAND ARGUMENT PROCESSING
# This option determines whether or not the NRPE daemon will allow clients
# to specify arguments to commands that are executed.  This option only works
# if the daemon was configured with the --enable-command-args configure script
# option.  
#
# *** ENABLING THIS OPTION IS A SECURITY RISK! *** 
# Read the SECURITY file for information on some of the security implications
# of enabling this variable.
#
# Values: 0=do not allow arguments, 1=allow command arguments
dont_blame_nrpe=1
Next change you command definition for check_oim:

Code: Select all

command[check_oim]=/usr/local/nagios/libexec/check_oim $ARG1$ $ARG2$
Otherwise, if this is not needed you can enter the arguments in to the command definition (change 127.0.0.1 to the correct ip address):

Code: Select all

/usr/local/nagios/libexec/check_oim 127.0.0.1 nossl
After making changes to NRPE, re-start the service either with service nrpe restart or service xinetd restart depending on how it was installed.

If you're having issues from the Nagios server, try to test it by pushing all the options into one argument with the -a option ( see this ).

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1  -c check_oim -a '127.0.0.1 nossl'