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

NRPE: Unable to read output

Post 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
Attachments
jmeter.pl
(5.45 KiB) Downloaded 503 times
Last edited by dwhitfield on Fri Nov 18, 2016 11:04 am, edited 2 times in total.
Reason: marking with green check mark
User avatar
lgroschen
Posts: 384
Joined: Wed Nov 27, 2013 1:17 pm

Re: NRPE: Unable to read output

Post 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
/Luke
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post 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
User avatar
lgroschen
Posts: 384
Joined: Wed Nov 27, 2013 1:17 pm

Re: NRPE: Unable to read output

Post by lgroschen »

Try running through this doc, it might be a simple permission issue: https://assets.nagios.com/downloads/nag ... utions.pdf
/Luke
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post 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
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: NRPE: Unable to read output

Post 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.
Former Nagios Employee
natalia.fitsyk
Posts: 29
Joined: Mon Aug 22, 2016 8:14 am

Re: NRPE: Unable to read output

Post 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
Last edited by dwhitfield on Fri Oct 14, 2016 10:42 am, edited 2 times in total.
Reason: editing code blocks
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE: Unable to read output

Post 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
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,
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
Last edited by dwhitfield on Thu Oct 13, 2016 9:51 am, edited 1 time in total.
Reason: code blocks FTW
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 »

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.
Locked