NRPE:Unable to read output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

NRPE:Unable to read output

Post 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.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE:Unable to read output

Post 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.
Former Nagios employee
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: NRPE:Unable to read output

Post 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?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: NRPE:Unable to read output

Post 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)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: NRPE:Unable to read output

Post 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?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE:Unable to read output

Post 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.
Former Nagios employee
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: NRPE:Unable to read output

Post 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]#
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: NRPE:Unable to read output

Post by tmcdonald »

And you did run the ./configure before, correcT?
Former Nagios employee
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

Re: NRPE:Unable to read output

Post 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.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE:Unable to read output

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked