Page 1 of 4

NRPE:Unable to read output

Posted: Fri Jul 18, 2014 12:48 pm
by snapon_admin
How difficult would it be to modify check_nrpe to return code 3 for "cannot read output" instead of a warning code? The only reason I ask is because we have a zone memory and zone CPU check that runs a prstat -Z on our global servers and greps the zone name to tell us how much memory and CPU our zones are using. Well, whenever we patch our servers, all of our NRPE checks work fine, except for these zone checks which means lots and lots of notifications are being sent. Currently, we aren't sending email notifications for "Unknown" status alerts, so if we could change this "unable to read output" exit code to come up as unknown that would solve our issue.

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:02 pm
by tmcdonald
Not *too* hard I wouldn't think. Relevant code in send_nrpe.c line 311:

Code: Select all

		/* print the output returned by the daemon */
		receive_packet.buffer[MAX_PACKETBUFFER_LENGTH-1]='\x0';
		if(!strcmp(receive_packet.buffer,""))
			printf("CHECK_NRPE: No output returned from daemon.\n");
		else
			printf("%s\n",receive_packet.buffer);
Probably wanna throw an else if in there to check for "Unable to read output" and act set the var "result" to 3.

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:10 pm
by snapon_admin
Should have specified on my lack of coding knowledge, lol. The check_nrpe I have on my server appears to already be compiled, and thus cannot be modified. How would I go about modifying the appropriate lines?

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:16 pm
by abrist
Probaly not that hard. Grab the source for nrpe from github. Edit:

Code: Select all

nrpe.c
Change lines 1389-1390 from:

Code: Select all

else if(!strcmp(buffer,""))
    snprintf(buffer,sizeof(buffer)-1,"NRPE: Unable to read output\n");
To:

Code: Select all

else if(!strcmp(buffer,"")) {
       snprintf(buffer,sizeof(buffer)-1,"NRPE: Unable to read output\n");
    	result=STATE_UNKNOWN;
}
And rebuild.
Please note - *I have not tested this* :P (It is but conjecture)

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:44 pm
by snapon_admin
sorry if this is a stupid question, but I need more info on the "rebuild part". I'm not a programmer, just a lowly netadmin that got stuck with Nagios (new guy, etc.) so this kind of thing isn't one of my stronger areas. I've modified the nrpe.c file, and looking at the readme it looks like I need to

Code: Select all

./compile
make all
Is that correct? If so, where does it put the new check_nrpe? Do I also need to roll out a new nrpe.conf to all our servers?

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:48 pm
by tmcdonald
Usually it's

Code: Select all

./configure
make
make install
Might not need the second step here, but it won't break anything.

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 1:55 pm
by snapon_admin
Ah gotcha. K, I'm no expert (again), but it looks like I'm getting an error after the 'make install' command:

Code: Select all

[root@nagiosTEST nrpe-2.15]# make install
cd ./src/ && make install
make[1]: Entering directory `/tmp/nrpe-2.15/src'
make install-plugin
make[2]: Entering directory `/tmp/nrpe-2.15/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
/usr/bin/install: cannot stat `check_nrpe': No such file or directory
make[2]: *** [install-plugin] Error 1
make[2]: Leaving directory `/tmp/nrpe-2.15/src'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/tmp/nrpe-2.15/src'
make: *** [install] Error 2
[root@nagiosTEST nrpe-2.15]#

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 2:01 pm
by tmcdonald
And you did run the ./configure before, correcT?

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 2:03 pm
by snapon_admin
Yep. Ran all three actually, ./configure, make, make install. No errors that I can see from the ./configure or 'make', but I can copy all of that in too if you want in case I missed something.

Re: NRPE:Unable to read output

Posted: Fri Jul 18, 2014 2:27 pm
by lmiltchev
Sometimes you can get this error if openssl-devel package is not installed. Try running:

Code: Select all

yum install openssl-devel -y
Then try to recompile again. Let me know if this helped.