Free disk space and other host-level measurements cannot be checked with a network connection alone. On Ubuntu hosts, NRPE lets Nagios Core monitor these measurements by requesting a plugin result from the remote machine.

The monitoring server runs check_nrpe, while the monitored host runs the NRPE daemon and the disk plugin. A working source installation of Nagios Core and a signed-in Nagios web interface are the starting point; the NRPE components come from Ubuntu's packages. The remote disk result becomes a service attached to the monitored host.

An allowed NRPE client can invoke the commands exposed by the agent. The monitored host therefore needs a firewall or network ACL that permits TCP port 5666 only from the monitoring server. Fixed command arguments keep the disk check limited to the selected filesystem without allowing the client to choose arbitrary plugin arguments.

Steps to monitor a Linux host with NRPE in Nagios Core:

  1. Install the NRPE client plugin on the Nagios Core server.
    $ sudo apt install nagios-nrpe-plugin

    The server uses the Ubuntu package's /usr/lib/nagios/plugins/check_nrpe binary even when Nagios Core itself was built from source.

  2. Install the NRPE daemon and disk plugin on the monitored Ubuntu host.
    $ sudo apt install nagios-nrpe-server monitoring-plugins-basic

    The monitored host is the remote system whose disk usage Nagios will report.
    Related: How to install the NRPE agent on Linux for Nagios Core

  3. Back up the monitored host's NRPE configuration before changing its client access list.
    $ sudo cp -a /etc/nagios/nrpe.cfg /etc/nagios/nrpe.cfg.before-nrpe

    An incorrect access list can stop existing NRPE checks. The saved copy provides a way back by restoring the file and restarting nagios-nrpe-server.

  4. Add the monitoring server's IP address to the existing allowed_hosts line in /etc/nagios/nrpe.cfg on the monitored host.
    $ sudoedit /etc/nagios/nrpe.cfg
    allowed_hosts=127.0.0.1,::1,192.0.2.10

    192.0.2.10 represents the monitoring server's source address as seen by the agent. Existing authorized addresses stay on the same comma-separated line. The packaged dont_blame_nrpe=0 setting keeps client-supplied arguments disabled.

  5. Create check_disk_root.cfg in the monitored host's /etc/nagios/nrpe.d directory with the fixed root-filesystem check.
    $ sudoedit /etc/nagios/nrpe.d/check_disk_root.cfg
    command[check_disk_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /

    The Ubuntu configuration includes this directory automatically. The warning threshold is 20% free space and the critical threshold is 10%; the output also reports inode availability. No sudo rule is needed for this disk check.
    Related: How to add an NRPE command for Nagios Core

  6. Restart the NRPE service on the monitored host to apply the saved configuration.
    $ sudo systemctl restart nagios-nrpe-server
  7. Run the remote disk check from the Nagios Core server.
    $ /usr/lib/nagios/plugins/check_nrpe -H web01.example.net -c check_disk_root
    DISK OK - free space: / 63625MiB (55% inode=87%);| /=53319041024B;101195133747;113844525465;0;126493917184

    web01.example.net must resolve to the monitored host from the monitoring server. Free-space values vary by host; DISK OK means the filesystem is above its warning thresholds. A refused connection points to the agent's access list, service, or firewall path; an undefined-command response points to the command name or loaded drop-in.
    Related: How to run a Nagios plugin manually

  8. Create web01-nrpe.cfg in the monitoring server's /usr/local/nagios/etc/objects directory with the NRPE command, host, and disk service definitions.
    $ sudoedit /usr/local/nagios/etc/objects/web01-nrpe.cfg
    define command {
        command_name    check_nrpe_remote
        command_line    /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
    }
     
    define host {
        use             linux-server
        host_name       web01.example.net
        alias           Web server 01
        address         web01.example.net
    }
     
    define service {
        use                     generic-service
        host_name               web01.example.net
        service_description     Disk Usage
        check_command           check_nrpe_remote!check_disk_root
    }

    If this host is already defined in Nagios, omit the new define host block and use its existing host_name in the service. If check_nrpe_remote already exists, retain a single matching command definition. $ARG1$ selects the named NRPE command; its disk thresholds remain fixed on the agent.
    Related: How to add a host in Nagios Core
    Related: How to add a service check in Nagios Core
    Related: How to define a Nagios Core check command

  9. Add the new object file at the end of the server's /usr/local/nagios/etc/nagios.cfg.
    $ sudoedit /usr/local/nagios/etc/nagios.cfg
    cfg_file=/usr/local/nagios/etc/objects/web01-nrpe.cfg

    If an existing cfg_dir already loads this file's directory, no extra cfg_file entry is needed. Loading the same objects twice causes duplicate-definition errors.

  10. Validate the Nagios configuration before applying the new service.
    $ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    ##### snipped #####
    Total Warnings: 0
    Total Errors:   0
    
    Things look okay - No serious problems were detected during the pre-flight check

    Configuration errors must be resolved before reloading Nagios. Removing the new cfg_file entry reverses this addition without changing the existing monitoring objects.
    Related: How to validate the Nagios Core configuration

  11. Reload Nagios Core to start scheduling the remote disk service.
    $ sudo systemctl reload nagios
  12. Open Services under Current Status in the signed-in Nagios web interface.
  13. Confirm that Disk Usage for web01.example.net has an OK state and DISK OK status information after its first scheduled check.

    PENDING means the service has not run yet. A Last Check timestamp and disk result distinguish a completed check from an untested definition. A low-space WARNING or CRITICAL result requires attention to the remote filesystem.
    Related: How to reschedule an active check in Nagios Core

Share this guide