5

I'm trying to use check_nrpe to check on a remote server, but it's not working and I can't figure out what am I missing...

# /usr/lib/nagios/plugins/check_nrpe -H XXX -c check_load -a 6,5,4 8,7,6
NRPE: Unable to read output
# 

remote's server syslog message:

nrpe[18058]: Connection from XX.XX.XX.XX port 16267
nrpe[18058]: Host address is in allowed_hosts
nrpe[18058]: Handling the connection...
nrpe[18058]: Host is asking for command 'check_load' to be run...
nrpe[18058]: Running command: /usr/bin/sudo /usr/lib64/nagios/plugins/check_load -w 6,5,4 -c 8,7,6
nrpe[18058]: Command completed with return code 1 and output: 
nrpe[18058]: Return Code: 1, Output: NRPE: Unable to read output
nrpe[18058]: Connection from XX.XX.XX.XX closed.

to verify it manually, I issue same command on a remote shell:

bash-4.1$ id
uid=497(nrpe) gid=497(nrpe) groups=497(nrpe) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
bash-4.1$ /usr/bin/sudo /usr/lib64/nagios/plugins/check_load -w 6,5,4 -c 8,7,6
OK - load average: 0.21, 0.23, 0.19|load1=0.210;6.000;8.000;0; load5=0.230;5.000;7.000;0; load15=0.190;4.000;6.000;0; 
bash-4.1$ 
alexus
  • 12,342
  • 27
  • 115
  • 173
  • I'd run `strace` on the nrpe process and then run the `check_nrpe` to get some insight. Also, why do you need to run check_load as root? That info is available to non-root users. – Mark Wagner May 18 '14 at 00:26
  • @Jenny-D that one seemed to be a rights issue whereas this one doesn't. – Mark Wagner May 18 '14 at 00:27
  • @JennyD seems like entirely different issue, even though w/ same output, please don't close it. – alexus May 19 '14 at 14:47
  • @alexus Closing is not something one person does - it needs five people who all agree. If none of the answers in that post helped you, please add what you tried and what happened to your own question. – Jenny D May 19 '14 at 14:59
  • @JennyD I did that while posting question, the only person who post an answer was scott-- (who didn't seem like even read my entire question as what he suggested was posted in my original question at the time of post) – alexus May 19 '14 at 15:07
  • I meant the answers on the other post. There are several different suggestions there. – Jenny D May 19 '14 at 15:24
  • Have you checked that check_load on remote host is owned by appropriate user or group? – Gehendra Acharya Nov 21 '14 at 02:01

3 Answers3

6

... the issue was even though nrpe_user inside of /etc/nagios/nrpe.cfg was set to nrpe, for whatever reason nrpe was running as nagios user instead, so I had to readjust sudoers.d file and it's start working right away ...

# grep nrpe_user /etc/nagios/nrpe.cfg
nrpe_user=nrpe
# ps auxwww | grep nrpe
nagios   25388  0.0  0.0  41332  1240 ?        Ss   11:32   0:00 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
root     26230  0.0  0.0 103252   828 pts/3    S+   11:47   0:00 grep nrpe
# cat /etc/sudoers.d/01_nagios 
Defaults:nagios !requiretty
nagios      ALL=(ALL)   NOPASSWD:   /usr/lib64/nagios/plugins/
# 
alexus
  • 12,342
  • 27
  • 115
  • 173
  • Why are you using sudo for check_load? This is unnecessary (and would have spared you this trouble). Only a handful of checks need sudo/root. – Keith May 20 '14 at 21:09
  • @Keith I use `sudo` for all nagios's nrpe calls (per company policy), as it allows to execute commands as another user. – alexus May 21 '14 at 02:12
1

This can be caused by sudo's "requiretty" setting. The real question, though, is why you're running check_load through sudo anyway.

So, to fix this: either disable requiretty (just for the nagios/nrpe user) or stop running the plugin through sudo.

Keith
  • 4,627
  • 14
  • 25
-1

On the machine being checked, locate the nrpe.cfg file and inside that, the entry for "check_load". It will look something like this:

command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

Try running the command on that machine - everything to the right of the equals sign above and see what you get.

/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

I'll bet its looking for check_load in /usr/lib/nagios/plugins instead of /usr/lib64 or something like that.

scott--
  • 107
  • 5