NRPE: Unable to read output

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post by natalia.fitsyk »

Hi,
[root@cleint_nrpe~]# more /usr/local/nagios/libexec/check_site.sh
#!/bin/bash
sudo /home/nagios/apache-jmeter-3.0/bin/jmeter.pl -j /home/nagios/apache-jmeter-3.0/ -p /home/nagios/apache-jmeter-3.0/bin/dermsl01_buono.jmx -w 15 -c 30

Thanks.
Natalia
Attachments
jmeter.pl
(5.25 KiB) Downloaded 287 times
nrpe.cfg
(7.93 KiB) Downloaded 281 times
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: NRPE: Unable to read output

Post by dwhitfield »

We will leave this open for community input. Unfortunately, we cannot fully support custom development.
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post by natalia.fitsyk »

Any suggestions?
Thanks everyone.
Natalia.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: NRPE: Unable to read output

Post by dwhitfield »

Looking back through the thread, we never got a description of what it is you are trying to accomplish with your script. If you could explain that, we can help better with the script. Thanks!
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post by natalia.fitsyk »

EDIT: Please use code tags

Hi,
I need to monitor my website, I created a jmeter test and now with help of nrpe I need to monitor my website.
Jmeter try to login and check availability from more parts of the site and check the response times.
ex:

Code: Select all

[root@client_nrpe ~]# /usr/local/nagios/libexec/check_site.sh
OK : sum:2542 : 2.542 seconds to complete.

Code: Select all

[root@client_nrpe ~]# su - nrpe
-bash-4.1$ sudo /usr/local/nagios/libexec/check_site.sh
+ sudo /usr/local/nagios/libexec/apache-jmeter-3.0/bin/jmeter.pl -j /usr/local/nagios/libexec/apache-jmeter-3.0/ -p /usr/local/nagios/libexec/apache-jmeter-3.0/bin/dermsl01_buono.jmx -w 15 -c 30
OK : sum:5656 : 5.656 seconds to complete.
-bash-4.1$ sudo  /usr/local/nagios/libexec/check_nrpe -H localhost -c check_jmeter
NRPE: Unable to read output
-bash-4.1$ sudo /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
USERS OK - 1 users currently logged in |users=1;5;10;0
-bash-4.1$ sudo /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
OK - load average: 0.00, 0.01, 0.00|load1=0.000;15.000;30.000;0; load5=0.010;10.000;25.000;0; load15=0.000;5.000;20.000;0;
Thanks.
Natalia
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NRPE: Unable to read output

Post by mcapra »

On the remote machine, can you share the contents of /usr/local/nagios/libexec/check_site.sh? Be sure to sanitize any JMX credentials in-use.

Can you also share the output of the following command from the remote machine's CLI:

ls -al /usr/local/nagios/libexec/
Former Nagios employee
https://www.mcapra.com/
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post by natalia.fitsyk »

[root@client_nrpe]# more /usr/local/nagios/libexec/check_site.sh
#!/bin/bash
sudo /usr/local/nagios/libexec/apache-jmeter-3.0/bin/jmeter.pl -j /usr/local/nagios/libexec/apache-jmeter-3.0/ -p /usr/local/nagios/libexec/apache-jmeter-3.0/bin/de_buono.jmx
I attached the list
"ls -al /usr/local/nagios/libexec/"

Thanks.
Natalia
Attachments
listanrpe.txt
(4.16 KiB) Downloaded 314 times
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: Unable to read output

Post by tgriep »

I see that you have debugging enabled in the nrpe.cfg file, when that command that creates the error is run, you you see any errors in the syslog files which are usually in the /var/log folder?
Another thing to try is to edit the script and put the full path to the sudo command and see if that helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post by natalia.fitsyk »

Hi,
1. there are the log :
Connection from localhost port 9097
Host address is in allowed_hosts
Handling the connection...
Host is asking for command 'check_jmeter' to be run...
Running command: /usr/bin/sudo /usr/local/nagios/libexec/check_site.sh
Command completed with return code 1 and output:
Return Code: 1, Output: NRPE: Unable to read output
Connection from ▒▒▒h▒#177 closed.
Connection from localhost port 9609
Host address is in allowed_hosts
Handling the connection...
Host is asking for command 'check_swap' to be run...
Running command: /usr/bin/sudo /usr/local/nagios/libexec/check_swap -w 20% -c 10%
Command completed with return code 1 and output:
Return Code: 1, Output: NRPE: Unable to read output
Connection from ▒▒▒h▒#177 closed.

I created new plugin for another test "check_swap" and I have the same output, I think I missing sudo but I don't know where.

But when I exec check_swap manualy the function is correctly:
[root@client_nrpe ~]# /usr/local/nagios/libexec/check_swap -w 20% -c 10%
SWAP OK - 100% free (4077 MB out of 4094 MB) |swap=4077MB;818;409;0;4094

2. Yes I try but the output is same.

Thanks.
Natalia
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: Unable to read output

Post by tgriep »

Try logging in to the remote system and change to the nrpe user by running

Code: Select all

su nrpe
Then run the command that you have defined in the nrpe.cfg line the example below.

Code: Select all

/usr/bin/sudo /usr/local/nagios/libexec/check_swap -w 20% -c 10%
You will probable see and error similar to below.
Sorry, user nrpe is not allowed to execute '/usr/local/nagios/libexec/check_swap -w 20% -c 10%' as root on localhost.localdomain.

If you see that error, try running it without sudo in the command like the following

Code: Select all

/usr/local/nagios/libexec/check_swap -w 20% -c 10%
If it works, remove the /usr/bin/sudo from your commands and that should fix it for you.

One thing to note, you are running the agent as the nrpe user and the plugins are installed as the nagios user account.
You may have to adjust the owner of the plugins to the nrpe user to get them to function.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked