NRPE unable to read output, but why?
Solution 1:
You have a rights problem.
Change the command to:
command[check_openmanage]=sudo /usr/lib/nagios/plugins/additional/check_openmanage -s -e -b ctrl_driver=0 bat_charge
(add sudo)
Then, add the nagios-user to the sudoers:
nagios ALL=(ALL) NOPASSWD:/usr/lib/nagios/plugins/additional/check_openmanage
Or you could just chmod the file... That also works.
If you are using CentOS, Red Hat, Scientific or Fedora, make sure to disable Defaults requiretty
in the sudoers file.
Solution 2:
Short answer : if you're using a Bash plugin, make sure you have a shebang stating which interpreter should be used : #!/bin/bash
I was facing the same issue with a Nagios plugin I wrote myself. The script was running as expected when launched locally, even when running as user nagios
using following statement :
$ sudo sudo -s -u nagios
$ /path/to/my/plugin.sh
STATUS: OK
But remote-launching using NRPE from the Nagios3 server was unsuccessful :
$ /usr/lib/nagios/plugins/check_nrpe -H my-nagios-client -c my_plugin
NRPE: Unable to read output
I finally solved this case by adding a shebang in my script, as it appeared that running the script through NRPE did not used the same interpreter as when running through sudo sudo -s -u nagios
.
Solution 3:
In my case problem was simply - user nagios was not able to execute the script. After chmod it started to worked. Sudo is not necessary. Its even evil :)
Solution 4:
check_nrpe was getting 'NRPE: Unable to read output' despite the check working locally because the plugin I was using did not work well with SELinux. Disable it and make sure to remove the file's contexts:
$ ls -l check_om_storage
-r-xr-xr--. 1 root nrpe 3808 Feb 27 17:54 check_om_chassis
$ setfattr -x security.selinux check_om_storage
$ ls -l check_om_chassis
-r-xr-xr-- 1 root nrpe 3808 Feb 27 17:54 check_om_chassis
Solution 5:
Check pathing, permissions, selinux, iptables.
Mine was a pathing issue in client:nrpe.cfg, double check the command path to the check_* plugin name. These can be confusing, (lib/local) (libexec/plugins) as a pathname. I mistakenly yanked and put the paths from the commented prepackaged nrpe cfg file to make commands. The make install or yum plugin install puts these in a difft directory.
commaneted: /usr/local/nagios/libexec/check_disk
versus
realpath: /usr/lib/nagios/plugins/check_disk
From the server I was able to confirm it was not a firewall issue, could telnet to the 5666 port, could run a blanket check_nrpe and get the status as a return value. Could run the commands locally but nrpe had the wrong path on the client in the nrpe.cfg.