Page 1 of 1

NRPE: Unable to read output

Posted: Fri Feb 10, 2017 9:19 am
by nagios_aws
Hello,

after going through all the Internet about this problem, here I'm to ask for help :

I can get version of NRPE agent on the remote RHEL:

Code: Select all

[user@server ~]# /usr/local/nagios/libexec/check_nrpe -H HOSTNAME
NRPE v2.15
but it don't work on the machine itself :

Code: Select all

[nagios@server libexec]$ ./check_nrpe -H 127.0.0.1
CHECK_NRPE: Error - Could not complete SSL handshake.
I can run some checks:

Code: Select all

[user@server ~]# /usr/local/nagios/libexec/check_nrpe -H HOSTNAME -c check_load -a "-w 15,10,5 -c 30,25,20"
OK - load average: 0.04, 0.03, 0.00|load1=0.040;15.000;30.000;0; load5=0.030;10.000;25.000;0; load15=0.000;5.000;20.000;0;
but i'm not able to use a check of my own:

Code: Select all

[user@server ~]# /usr/local/nagios/libexec/check_nrpe -H HOSTNAME-c unix_flexlm -a "1735"
NRPE: Unable to read output
You can find my nrpe.cfg file in attachment
my check launch a perl script which use an executable placed in "/usr/local/nagios/bin/", all rights should be good, according to your answers to others posts .
the NRPE port is accessible from outside (seen using nmap command) also

thank you for your answers

Re: NRPE: Unable to read output

Posted: Fri Feb 10, 2017 10:36 am
by rkennedy
but it don't work on the machine itself :

CODE: SELECT ALL
[nagios@server libexec]$ ./check_nrpe -H 127.0.0.1
CHECK_NRPE: Error - Could not complete SSL handshake.
There is no point in running check_nrpe against 127.0.0.1 - this defeats the purpose as using an agent to monitor. The agent is meant to interact with other machines. The likely error here is you probably don't have 127.0.0.1 on the allowed hosts, or it's trying to push through with IPv6.

I'll address the real problem here -

Code: Select all

[user@server ~]# /usr/local/nagios/libexec/check_nrpe -H HOSTNAME-c unix_flexlm -a "1735"
NRPE: Unable to read output
This is generally due to permissions of some sort. What happens if you run su - nagios and attempt to run it manually?

Re: NRPE: Unable to read output

Posted: Mon Feb 13, 2017 3:17 am
by nagios_aws
Hello,

yeah, i tried the thing on the machine itself just to be sure and rule out this.

By using the nagios user on the Nagios server and launch this :

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H HOSTNAME-c unix_flexlm -a "1735"
I got the same error as before.

I can run the Perl script on the machine as nagios user, I can launch some NRPE check from Nagios Server as root or nagios user, but I can't run my Perl through NRPE in any way.

Thank you

Re: NRPE: Unable to read output

Posted: Mon Feb 13, 2017 4:45 am
by nagios_aws
oh, and when I try to launch a NRPE request from Nagios server, here is the /var/log/messages :

Code: Select all

Feb 13 10:41:31 HOST xinetd[52369]: START: nrpe pid=52448 from=::XX.XX.XX.XX.XX
Feb 13 10:41:31 HOST nrpe[52448]: INFO: SSL/TLS initialized. All network traffic will be encrypted.
Feb 13 10:41:31 HOST  xinetd[52369]: EXIT: nrpe status=0 pid=52448 duration=0(sec)
I'm pretty sure that I don't have SSL or TLS enabled on this agent ...

Re: NRPE: Unable to read output

Posted: Mon Feb 13, 2017 5:19 am
by nagios_aws
And I just tried the nrpe thing in /etc/sudoers, it doesn't work either.

NRPE is launched through xinetd, and under the user "nagios" (found in /etc/xinetd.d/nrpe)

all of my customs file belongs to nagios user, all other belongs to root. I tried to change those but it doesn't care, it works as now.

Re: NRPE: Unable to read output

Posted: Mon Feb 13, 2017 9:15 am
by nagios_aws
I finally managed to find the issue :

when I called my plugin from the directory where it was, it worked using the absolute path
but when I tried to do the same thing from another directory, it cannot find the perl file called in it.

so here is what I've done :

Code: Select all

my $prgname = $0;
if(substr($prgname,0,1) eq '/'){
        my $path = $prgname;
        $prgname =~ s/^(.+)\/.*?$/$1/;
        chdir($prgname);
}
this way, path are correctly set, too bad that I found the issue by luck and not in a log :?

Re: NRPE: Unable to read output

Posted: Mon Feb 13, 2017 10:42 am
by lmiltchev
I am glad your issue has been resolved! Is it OK if we lock this topic? Thanks!