Icinga NRPE Plugin how-to

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

Nagios Remote Plugin Executor (NRPE) is a module for executing Nagios & Icninga Plugins and processing their output in turn locally. NRPE can be used when SNMP should, or can, not be used.[1] "check_by_ssh" is an alternative to NRPE which establishes an SSH connection for monitoring the remote target, in order to execute plugins.[2] The use of SSL is also recommended for constructing an encrypted connection with check_nrpe. This article will show how to configure the Nagios/Icinga client and Icinga server under Debian Squeeze for executing plugins on the client via "check_nrpe".

Nagios/Icinga Client

The Nagios/Icinga client is the remote computer which should be monitored by NRPE. For that reason, the NRPE server is installed first:

sudo apt-get install nagios-nrpe-server

So that the Icinga server can be connected with the daemon, its IP address must be added to the configuration file (in this case, 10.0.0.3):[3]

sudo vi /etc/nagios/nrpe.cfg
...
allowed_hosts=127.0.0.1,10.0.0.3
...

Finally, the access of the NRPE daemon to the nagios plugins will be set. After installation (such as by the "nagios-plugins" package), they should be found under "/usr/lib/nagios/plugins/". So that the NRPE daemon can interpret the incoming "check_load" command, where this command should point to is set in a configuration file. Several commands already exist in the supplied "nrpe.cfg" file. New commands can be specified, for example, in the "nrpe_local.cfg" file.

:~# cat nrpe.cfg |grep check_load
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

If changes have been made to the configuration, the daemon will have to be re-started.

sudo /etc/init.d/nagios-nrpe-server restart

Icinga Server

The existence of an Icinga installation (cp. Icinga 1.6.1 Installation under Debian 6.0 Squeeze) on the server is a prerequisite. Additionally, the "nagios-nrpe-plugin" package must have been installed. In order to prevent Nagios from being installed as well, the "--no-install-recommends" option will be used:

apt-get --no-install-recommends install nagios-nrpe-plugin

The first test should check if the NRPE daemon can be reached on the client and will accept commands. The following command returns the version of the NRPE installation if the setup is correct:

:~# /usr/lib/nagios/plugins/check_nrpe -H 10.0.0.1
NRPE v2.12

This ensures that the host to be monitored can be reached and will respond to, and execute, NRPE inquiries. In the next step, commands will be defined for Icinga, which execute NRPE. The first command to be created will transfer existing parameters to check_nrpe:[4]

:~# vi /usr/local/icinga/etc/objects/commands.cfg:
###############################################################################
# NRPE CHECK COMMAND
#
# Command to use NRPE to check remote host systems
###############################################################################

define command{
        command_name check_nrpe
        command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }

The "check_nrpe" command just defined will be used in a new host configuration:

:~#  vi /usr/local/icinga/etc/objects/nrpe-client.cfg
define host{
        use             linux-server
        host_name       NrpeClient
        alias           NrpeClient
        address         10.0.0.1
        }
define service{
        use     generic-service
        host_name       NrpeClient
        service_description     CPU LOAD
        check_command   check_nrpe!check_load
        }

Our "CPU LOAD" service uses the check_nrpe command with the parameter "check_load". This parameter designates the script that will be executed on the monitored host (NRPE client). The NRPE daemon will accept the request and return the output of the script to the Icinga server. So that Icinga can load the new host configuration, the path to the Icinga configuration file will be added:

:~# vi /usr/local/icinga/etc/icinga.cfg 
cfg_file=/usr/local/icinga/etc/objects/nrpe-client.cfg

Finally, the following picture shows the execution of the process.

Nrpe-aufbau.png

References

  1. Icinga NRPE Instructions (docs.icinga.org)
  2. check_by_ssh Plugin (nagios.wiki.de)
  3. Setting up NRPE with Icinga (wiki.icinga.org)
  4. Icinga NRPE Documentation (docs.icinga.org)

Related articles

Adaptec RAID Monitoring Plugin setup
Install Intel Data Center Manager
LSI RAID Monitoring Plugin setup