Page 1 of 4

NRPE: Unable to read output

Posted: Wed Oct 05, 2016 2:37 am
by natalia.fitsyk
Hi,
I have a problem with my custom plugin.
I use nagios plugin jmeter.pl

Code: Select all

[root@client_nrpe ~]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_jmeter
NRPE: Unable to read output
output from more /etc/nagios/nrpe.cfg

Code: Select all

command[check_jmeter]=/usr/bin/sudo /usr/local/nagios/libexec/check_site.sh -w 1 -c 1
this is my script for jmeter:

Code: Select all

more /usr/local/nagios/libexec/check_site.sh
#!/bin/bash
sudo -u nrpe 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

Code: Select all

[root@client_nrpe ~]# grep nrpe /etc/sudoers
nrpe          ALL=(ALL)NOPASSWD: /usr/local/nagios/libexec/check_jmeter, /usr/local/nagios/libexec/check_nrpe, /usr/local/nagios/libexec/check_site.sh, /usr/local/nagios/libexec/script_jmeter.sh, /home/nagios/apache-jmeter-3.0/bin/jmeter, /root/apache-jmeter-3.0/bin/jmeter.pl, /home/nagios/apache-jmeter-3.0/bin/jmeter.pl

Code: Select all

[root@client_nrpe ~]# ll /usr/local/nagios/libexec/check_site.sh
-rwxrwxrwx 1 nrpe nagios 570 Oct  3 18:14 /usr/local/nagios/libexec/check_site.sh
This is the output when I execute the script for check_site.sh:

Code: Select all

[root@client_nrpe ~]# /usr/local/nagios/libexec/check_site.sh
OK : sum:15730 : 15.73 seconds to complete.
This is the output from check_users

Code: Select all

[root@client_nrpe ~]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
USERS OK - 2 users currently logged in |users=2;5;10;0
Iptables and Selinux are off.

Can you help me please?
Thanks.
Natalia

Re: NRPE: Unable to read output

Posted: Wed Oct 05, 2016 2:02 pm
by lgroschen
Hello!

This is a common mistake when creating your own plugin. All you should have to do to fix this would be to follow the developer guidelines on how generate nagios style output like this:

Code: Select all

'label'=value[UOM];[warn];[crit];[min];[max]
Here is the resource. I'm sure there is a lot of stuff in this document that will help you make more plugins: https://nagios-plugins.org/doc/guidelines.html#AEN200

Let us know how this turns out! Would be happy to help

Re: NRPE: Unable to read output

Posted: Fri Oct 07, 2016 8:00 am
by natalia.fitsyk
Hi,
I edit the /etc/nagios/nrpe.cfg and change form value to "ARG"
from
command[check_jmeter]=/usr/bin/sudo /usr/local/nagios/libexec/check_site.sh -w 1 -c 1
to
command[check_jmeter]=/usr/bin/sudo /usr/local/nagios/libexec/check_site.sh -w $ARG1$ -c $ARG2$
restart nrpe but the output don't change:
[root@client_nrpe ~]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_jmeter
NRPE: Unable to read output
What is wrong?
Can you help me please?
Thank.
Natalia

Re: NRPE: Unable to read output

Posted: Fri Oct 07, 2016 11:20 am
by lgroschen
Try running through this doc, it might be a simple permission issue: https://assets.nagios.com/downloads/nag ... utions.pdf

Re: NRPE: Unable to read output

Posted: Tue Oct 11, 2016 7:12 am
by natalia.fitsyk
Hi,
I have checked every suggestion about my check_custom but I don't find errors.
Can anyone help me please?
Thanks.
Natalia

Re: NRPE: Unable to read output

Posted: Tue Oct 11, 2016 11:04 am
by rkennedy
When you run the check_nrpe from the command line on the Nagios machine, please run tail -f /var/log/messages on your client machine. (might vary depending on your OS)

This will show us why the check is failing.

Re: NRPE: Unable to read output

Posted: Wed Oct 12, 2016 2:22 am
by natalia.fitsyk
Hi,
I don't have any output on /var/log/messages when I run check_nrpe -H localhost -c check_jmeter :(
Thank.
Natalia

Re: NRPE: Unable to read output

Posted: Wed Oct 12, 2016 3:33 pm
by lmiltchev
I don't have any output on /var/log/messages when I run check_nrpe -H localhost -c check_jmeter :(
If you changed your command to:

Code: Select all

command[check_jmeter]=/usr/bin/sudo /usr/local/nagios/libexec/check_site.sh -w $ARG1$ -c $ARG2$
then you need to test it by running:

Code: Select all

./check_nrpe -H localhost -c check_jmeter -a 1 1
Note: "-a" is used to pass arguments. In this case, you are passing '1' for $ARG1$, and '1' for $ARG2$.

You have some entries in sudoers for the "nrpe" user. Do you actually have an "nrpe" user on this system? Can you test the command logged in as "nrpe" user?

Code: Select all

su nrpe
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
sudo /usr/local/nagios/libexec/check_site.sh -w 1 -c 1
./check_nrpe -H localhost -c check_jmeter -a 1 1

Re: NRPE: Unable to read output

Posted: Thu Oct 13, 2016 4:08 am
by natalia.fitsyk
Hi,
This is the output :

Code: Select all

[root@client_nrpe ~]# su nrpe
bash-4.1$ 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
OK : sum:4806 : 4.806 seconds to complete.
bash-4.1$ sudo /usr/local/nagios/libexec/check_site.sh -w 1 -c 1
OK : sum:2131 : 2.131 seconds to complete.
bash-4.1$ ./check_nrpe -H localhost -c check_jmeter -a 1 1
bash: ./check_nrpe: Permission denied
bash-4.1$ sudo ./check_nrpe -H localhost -c check_jmeter -a 1 1
[sudo] password for nrpe:
sudo: ./check_nrpe: command not found
bash-4.1$ pwd
When I run from login with nrpe user :

Code: Select all

-bash-4.1$ pwd
/var/run/nrpe
-bash-4.1$ ./check_nrpe -H localhost -c check_jmeter
-bash: ./check_nrpe: No such file or directory
-bash-4.1$ ./check_nrpe -H localhost -c check_jmeter -a 1 1
-bash: ./check_nrpe: No such file or directory
-bash-4.1$ 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
OK : sum:2427 : 2.427 seconds to complete.
-bash-4.1$ sudo /usr/local/nagios/libexec/check_site.sh -w 1 -c 1
OK : sum:2309 : 2.309 seconds to complete.
-bash-4.1$ ./check_nrpe -H localhost -c check_jmeter -a 1 1
-bash: ./check_nrpe: No such file or directory
-bash-4.1$ sudo ./check_nrpe -H localhost -c check_jmeter -a 1 1
[sudo] password for nrpe:
sudo: ./check_nrpe: command not found
Thanks a lot.
Natalia

Re: NRPE: Unable to read output

Posted: Thu Oct 13, 2016 10:16 am
by dwhitfield
rkennedy wrote:(might vary depending on your OS)
What OS and version are you running? If CentOS, you can get your version from rpm --query centos-release.