Home » Categories » Products » NRPE » Troubleshooting » Common Problems

NRPE - NRPE: Unable To Read Output

Problem Description

This KB article addresses the following NRPE error:

NRPE: Unable To Read Output

 

Assumed Knowledge

The following KB article contains an explanation of how NRPE works and may need to be referenced to completely understand the problem and solution that is provided here:

NRPE - Agent and Plugin Explained

 

Troubleshooting The Error

This error implies that NRPE did not return any character output. Common causes are incorrect plugin paths in the nrpe.cfg file or that the remote host does not have NRPE installed. There are also cases where the wrong interpreter is invoked when running the remote plugin. Rarely, it is caused by trying to run a plugin that requires root privileges.

 

Incorrect Plugin Paths

Log onto the remote host as root and check the plugin paths in /usr/local/nagios/etc/nrpe.cfg. Try to browse to the plugin folder and make sure the plugins are listed. Sometimes when installing from a package repo, the commands in nrpe.cfg will have a path to a distribution specific location. If the nagios-plugins package was installed from source or moved over from another remote host, they me be located in a different directory.

The default location for the nagios-plugins can be found at /usr/local/nagios/libexec/. Open up your nrpe.cfg file on the remote host and take note of the path for the command directives (in bold):

command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$

 

Change directory to this location and get a listing of this directories contents – you should see a large list of available plugins:

cd /usr/local/nagios/libexec/
ls

 

If the directory is blank or altogether missing, you are either missing the nagios-plugins, or they are in a different directory. You will need to change your nrpe.cfg file to reflect the location of your plugins.

 

 

Is NRPE Installed?

Next, make sure that NRPE is indeed installed on the remote host. Log onto the remote host as root and execute the following command:

find / -name nrpe

 

The results should be similar to the following:

/usr/local/nagios/bin/nrpe
/usr/local/nagios/etc/nrpe
---- Truncated --------

 

If NRPE is installed, refer to the following KB article to make sure that NRPE is actually running:

NRPE - CHECK_NRPE: Socket Timeout After n Seconds

 

If the remote host does not have NRPE, you will have to install it. This can be done in a few different ways. We suggest installing NRPE via the Linux agent provided by Nagios XI. Please reference the below link for instructions:

Installing the Linux NRPE Monitoring Agent:

https://assets.nagios.com/downloads/nagiosxi/docs/Installing_The_XI_Linux_Agent.pdf

 

However if you need to compile NRPE from source, please reference the link below for instructions:

Installing and Configuring NRPE from Source:

https://support.nagios.com/kb/article.php?id=515

 

 

The wrong interpreter is used when running the remote plugin

Every plugin written in a non-compiled (interpreted) language should have a line at the top similar to any of the following:

#/bin/bash
#/bin/sh
#/usr/bin/python

 

This is appropriate based on the plugin's language and the system on which it is running. This line tells the system what interpreter to use when running the plugin, and is called a "shebang". This line allows one to run a plugin/script without explicitly declaring the interpreter to use, like so:

./check_example

 

If the shebang is missing, you must directly invoke an interpreter like so:

bash ./check_example

 

Problems in NRPE can arise from any of the following situations regarding the shebang:

  • The shebang references the wrong path (/usr/bin/bash instead of /bin/bash)

  • The shebang references a missing interpreter (/bin/zsh instead of /bin/bash)

  • The shebang references /bin/sh or some other symlink to a missing interpreter

 

In the last case, a simple ls -lagainst the symlink will reveal the ultimate interpreter being used:

ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Dec  8 07:12 /bin/sh -> bash

 

Ensure that the symlink (->) points to the correct location of an existing interpreter.

 

 

The Plugin Requires "sudo" Privileges

It may be that your specific plugin requires root access. Depending on the Linux distribution on the remote host, you may have to consult the specific distribution's forums for instructions on how to give permission to the plugin and the user "nagios".  This example will use sudo and the /etc/sudoers file.

You will need to create a rule in /etc/sudoers for the user nagios and the plugin script/binary requiring root access. Additionally, if the plugin script calls another system binary that requires root access, you will need to specify a rule for that binary as well (this problem is most often found with raid array plugins that require an access to a third party utility that requires root access). Log into the remote host as root and edit the sudoers file using the following command:

visudo

 

The visudo command opens the /etc/sudoers file in vi, and when you save your changes and exit it will validate you have a valid sudoers file.

When using the vi editor, to make changes press i on the keyboard first to enter insert mode. Press Esc to exit insert mode.

You will need to add the following line (replace <plugin> with the file name of your plugin):

nagios   ALL = NOPASSWD:/usr/local/nagios/libexec/<plugin>

 

If your plugin requires another binary on the system that is restricted to root, you will have to create an additional rule (replace /path/to/binary with the actual path to the required binary):

nagios   ALL = NOPASSWD:/path/to/binary

 

This will allow the user "nagios" (the user that NRPE runs as) to run the specified plugin as root (through sudo) without a password. You should be very careful with these settings, as incorrectly configuring it will lead to LARGE security vulnerabilities.

When you have finished, save the changes in vi by typing:

:wq

and press Enter.

 

The final step is to add "sudo" to the command in the remote host's nrpe.cfg:

command[check_raid]=sudo /usr/local/nagios/libexec/check_raid

 

Now restart NRPE and verify the plugin works correctly. An additional test you can perform is to become the nagios user and then try and execute the plugin:

[root@centos12 ~]# su nagios
[nagios@centos12 root]$ sudo /usr/local/nagios/libexec/check_raid
output from plugin
[nagios@centos12 root]$ exit
[root@centos12 ~]#

 

Testing the plugin this way can help you see problems that you don't see through NRPE, like being prompted for a password.

 

 

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/

5 (1)
Article Rating (1 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
NRPE - Return Code Of 127 Is Out Of Bounds - Plugin May Be Missing
Viewed 2756 times since Fri, Jul 14, 2017
NRPE - Remote does not support Version 3 Packets
Viewed 4503 times since Mon, Nov 27, 2017
NRPE - UNKNOWN: No Handler For That Command
Viewed 6191 times since Mon, Jul 17, 2017
NRPE - Agent and Plugin Explained
Viewed 14657 times since Fri, Jul 14, 2017
NRPE - Turn Off XINETD Logging On Success
Viewed 5660 times since Tue, Mar 7, 2017
NRPE - CHECK_NRPE: Error Receiving Data From Daemon
Viewed 4280 times since Mon, Jul 17, 2017
NRPE - Connection Refused By Host
Viewed 7114 times since Mon, Jul 17, 2017
NRPE - CHECK_NRPE: Error - Could Not Complete SSL Handshake
Viewed 54137 times since Fri, Jul 14, 2017
NRPE - Connection Refused Or Timed Out
Viewed 3935 times since Mon, Jul 17, 2017
NRPE - Error While Loading Shared Libraries: libssl.so
Viewed 2987 times since Mon, Jul 17, 2017