-2

I have 2 centos server

Server 1 - centos 6.8

Server 2 - centos 6.7

Originaly I had the issue on Server 1 but was able to fix the issue I had with the fix explained here

NRPE unable to read output, but why?

When I try to the same fix on Server 2 i get the following error as explained in the above link.

root@server2 [/usr/local/nagios/libexec]# ./check_nrpe -H 127.0.0.1 -c check_exim
NRPE: Unable to read output

But if I run the command locally it works

root@server2 [/usr/local/nagios/libexec]#
/usr/local/nagios/libexec/check_exim_queue -c 20 -w 40 Mailqueue OK -
0 messages on queue

So to test I ran it as the user itself and it works

nagios@cloud-03 [/usr/local/nagios/libexec]# sudo /usr/local/nagios/libexec/check_exim_queue -c 20 -w 40
Mailqueue OK - 0 messages on queue

Any ideas will help

  • "*I ran it as the user itself ...*": no, you didn't. The `sudo` invocation you show, shows it running as root (as no user is specified). If you've become nagios, try just `/usr/local/nagios/libexec/check_exim_queue -c 20 -w 40`. – MadHatter Jul 06 '16 at 14:39
  • When running the command I get all is ok. But when I run `./check_nrpe -H 127.0.0.1 -c check_exim` i still het the error – edalb1979 Jul 06 '16 at 14:56
  • "*When running the command I get all is ok*": would you mind showing us that command, running on the client, as the `nagios` user? You haven't shown us that yet. The output of `grep check_exim /etc/nagios/nrpe.cfg` from the client would also be useful. – MadHatter Jul 06 '16 at 15:03

2 Answers2

0

Enable debug in nrpe agent

From:https://assets.nagios.com/downloads/nagioscore/docs/nrpe/NRPE.pdf

How to go about debugging other problems... When debugging problems it may be useful to edit the NRPE configuration file and change the debug=0 entry to debug=1. Once you do that, restart the NRPE daemon if it is running as a standalone daemon. After you try using the check_nrpe plugin again, you should be able to see some debugging information in the log files of the remote host. Check your logs carefully – they should be able to help provide clues as to where the problem lies...

NoNoNo
  • 1,939
  • 14
  • 19
  • I have set the debugging to 1 but the only output I am getting is `Jul 6 14:41:16 server2 xinetd[1999]: START: nrpe pid=2183 from=::ffff:127.0.0.1 Jul 6 14:41:16 server2 nrpe[2183]: INFO: SSL/TLS initialized. All network traffic will be encrypted. Jul 6 14:41:16 server2 xinetd[1999]: EXIT: nrpe status=0 pid=2183 duration=0(sec)` – edalb1979 Jul 06 '16 at 14:57
  • 1) Check your nrpe connection excluding the configuration of your command executing "/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1" shoud you give the NRPE version 2) Try to run the command ./check_nrpe -H 127.0.0.1 -c check_exim and check if the log in debug mode produce logs and report it here – NoNoNo Jul 07 '16 at 07:56
0

I was able to find the issue. The problem was with the check_mailq plugin. So after digging a bit and looking at it I was able to fix it.

The fix was adding the sudo command withing the script.

BEFORE

elsif ( $mailq eq "exim" ) {
        ## open mailq
        if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
                if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) )

After

elsif ( $mailq eq "exim" ) {
        ## open mailq
        if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
                if (! open (MAILQ, "/usr/bin/sudo $utils::PATH_TO_MAILQ | " ) )

So after making that change

    root@server2 [/usr/local/nagios/libexec]# ./check_nrpe -H 127.0.0.1 -c check_exim    
OK: mailq (0) is below threshold (20/40)|unsent=0;20;40;0

Thanks for the help