How to install the NRPE agent on Linux for Nagios Core

Local resource checks in Nagios Core need an agent when the status depends on data that only exists on the monitored Linux host. NRPE gives the monitoring server a small TCP listener that runs named Nagios plugins on that host and returns the plugin result.

The package path here uses current Debian and Ubuntu packages on the monitored host. The nagios-nrpe-server package installs the NRPE daemon, /etc/nagios/nrpe.cfg stores the main listener settings, /etc/nagios/nrpe.d can hold drop-in command files, and /usr/lib/nagios/plugins contains the plugins that NRPE runs.

The Nagios Core server reaches the agent with the check_nrpe plugin over TCP port 5666. Limit allowed_hosts to the monitoring server, keep dont_blame_nrpe disabled unless a specific command requires remote arguments, and verify one named command before adding NRPE service checks to Nagios object files.

Steps to install the NRPE agent on Linux:

  1. Open a terminal on the monitored Linux host with sudo privileges.
  2. Refresh the package index.
    $ sudo apt update
  3. Install the NRPE daemon and Nagios plugins on the monitored host.
    $ sudo apt install nagios-nrpe-server monitoring-plugins-basic monitoring-plugins-standard
    Reading package lists...
    The following NEW packages will be installed:
      monitoring-plugins-basic monitoring-plugins-standard nagios-nrpe-server
    ##### snipped #####
    Setting up nagios-nrpe-server (4.1.3-1ubuntu2) ...

    On RPM-based Linux hosts, install the supported nrpe package and matching monitoring plugins from the distribution, EPEL, or vendor repository used by that host.

  4. Open the NRPE configuration file.
    $ sudoedit /etc/nagios/nrpe.cfg
  5. Restrict NRPE access to localhost and the monitoring server.
    allowed_hosts=127.0.0.1,::1,192.0.2.20
    dont_blame_nrpe=0

    Replace 192.0.2.20 with the real Nagios Core server address. Do not add broad networks unless the host is inside a trusted monitoring subnet.

  6. Restart the NRPE service.
    $ sudo systemctl restart nagios-nrpe-server

    Restarting applies the changed allowed_hosts setting to the listener.
    Related: How to manage the Nagios Core system service

  7. Enable NRPE at boot.
    $ sudo systemctl enable nagios-nrpe-server

    Package installs on some systems start the service immediately, but enabling it keeps the listener available after a reboot.
    Related: How to manage the Nagios Core system service

  8. Confirm that the service is active.
    $ systemctl is-active nagios-nrpe-server
    active

    If the service is not active, inspect sudo journalctl -u nagios-nrpe-server before changing the Nagios server configuration.

  9. Run a default plugin locally on the monitored host.
    $ /usr/lib/nagios/plugins/check_users -w 5 -c 10
    USERS OK - 0 users currently logged in |users=0;5;10;0

    The default NRPE configuration exposes named commands such as check_users and check_load. Local plugin success confirms the plugin path works before the monitoring server calls it.

  10. Allow the monitoring server through UFW when UFW protects the host.
    $ sudo ufw allow from 192.0.2.20 to any port 5666 proto tcp
    Rule added

    Use the equivalent rule in firewalld, nftables, iptables, a host firewall, or a cloud security group when UFW is not the active firewall.

  11. Install the check_nrpe plugin on the Nagios Core server if it is not already installed.
    $ sudo apt install nagios-nrpe-plugin
  12. Test the NRPE listener from the Nagios Core server.
    $ /usr/lib/nagios/plugins/check_nrpe -H web01.example.net
    NRPE v4.1.3

    Replace web01.example.net with the monitored host name or address. A timeout points to routing, firewall, or allowed_hosts; a refused connection points to the NRPE service or listener address.

  13. Run a default remote plugin command from the Nagios Core server.
    $ /usr/lib/nagios/plugins/check_nrpe -H web01.example.net -c check_users
    USERS OK - 0 users currently logged in |users=0;5;10;0

    Add site-specific commands under /etc/nagios/nrpe.d after the agent is reachable.
    Related: How to add an NRPE command for Nagios Core
    Related: How to monitor a Linux host with NRPE in Nagios Core