UbuntuUbuntu Based

How To Install NRPE on Ubuntu 24.04 LTS

Install NRPE on Ubuntu 24.04 LTS

If you manage Linux servers without centralized monitoring, you are flying blind. A single undetected disk filling up or a runaway process can bring down a production environment before you even notice. NRPE (Nagios Remote Plugin Executor) solves this problem by giving your Nagios server eyes and ears on every remote host in your infrastructure. In this guide, you will learn exactly how to install NRPE on Ubuntu 24.04 LTS, configure it correctly, harden it for production, and verify that your Nagios server can pull live metrics from the remote Ubuntu machine.

Whether you are setting up monitoring for the first time or migrating an existing Nagios setup to Ubuntu 24.04 Noble Numbat, this tutorial covers every step with real commands, expected outputs, and explanations so you understand not just what to run but why you are running it. By the end, your Ubuntu 24.04 server will be actively monitored for CPU load, disk usage, memory, and running processes.

What is NRPE and How Does It Work?

Before running a single command, it pays to understand what NRPE actually does. Nagios Remote Plugin Executor is a lightweight daemon that runs on remote Linux hosts and acts as a local agent for the Nagios monitoring server.

The architecture has two moving parts:

  • check_nrpe plugin: Installed on the Nagios server. It sends a check request over TCP port 5666.
  • NRPE daemon: Installed on the client (your Ubuntu 24.04 server). It receives the request, runs the appropriate Nagios plugin locally, and sends the result back.

This design keeps all check logic on the client machine, which means Nagios does not need SSH access to the remote host. It also imposes far less system load than SSH-based checks, which is critical when you are monitoring dozens or hundreds of servers.

NRPE can monitor the following metrics on a remote host:

  • CPU load averages (1, 5, 15-minute intervals)
  • Disk usage on any mount point
  • Memory and swap utilization
  • Total running processes and zombie processes
  • Number of currently logged-in users
  • Any custom metric you define with a script

Prerequisites Before You Begin

This guide assumes you have the following in place before starting the NRPE on Ubuntu 24.04 setup process:

  • Operating system: Ubuntu 24.04 LTS (Noble Numbat) on the client machine.
  • Nagios server: A working Nagios Core or Nagios XI server already running on your network.
  • User privileges: Root or sudo access on the Ubuntu 24.04 client.
  • Network connectivity: The Nagios server must be able to reach the Ubuntu client over TCP port 5666.
  • Package repository access: The Ubuntu client needs access to the default apt repositories (internet or a local mirror).
  • Basic terminal knowledge: Familiarity with editing files using nano or vim.

You do not need to compile anything from source. The nagios-nrpe-server package is available directly from Ubuntu’s default repositories on 24.04.

Step 1: Update Your Ubuntu 24.04 System

Always update your system before installing new packages. This prevents dependency conflicts, ensures you get the latest security patches, and guarantees that the package index reflects the most current package versions available in the Ubuntu 24.04 repositories.

Open a terminal on your Ubuntu 24.04 server and run:

sudo apt update
sudo apt upgrade -y

What each command does:

  • sudo apt update refreshes the local package index against the Ubuntu repositories. It does not install or upgrade anything yet.
  • sudo apt upgrade -y applies all pending package upgrades and answers “yes” to any prompts automatically.

If the upgrade includes a kernel update, reboot the server before proceeding:

sudo reboot

After the reboot, reconnect via SSH and confirm you are running Ubuntu 24.04:

lsb_release -a

Expected output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble

Step 2: Install the NRPE Server and Nagios Plugins

With a clean and updated system, install NRPE and the Nagios plugin collection in one command.

sudo apt install nagios-nrpe-server nagios-plugins -y

This command installs two packages:

  • nagios-nrpe-server: The NRPE daemon binary, systemd service unit, and the default configuration file at /etc/nagios/nrpe.cfg.
  • nagios-plugins: A collection of over 50 monitoring scripts including check_disk, check_load, check_users, check_procs, and more. These are the actual scripts that NRPE runs locally when the Nagios server sends a check request.

During installation, apt automatically:

  1. Creates a system user and group named nagios
  2. Places the NRPE daemon binary at /usr/sbin/nrpe
  3. Registers a systemd service as nagios-nrpe-server
  4. Writes the default configuration to /etc/nagios/nrpe.cfg

Confirm the installation was successful by checking the NRPE version:

/usr/sbin/nrpe --version

Expected output:

NRPE - Nagios Remote Plugin Executor
Version: 4.0.3
...

If you see a version number, the binary installed correctly.

Step 3: Configure the NRPE Configuration File

This step is the most important part of the entire NRPE on Ubuntu 24.04 setup. Getting the configuration right determines whether the NRPE daemon accepts or rejects connections from your Nagios server.

Open the NRPE Configuration File

sudo nano /etc/nagios/nrpe.cfg

Set the Allowed Hosts Directive

Locate the allowed_hosts line. By default it reads:

allowed_hosts=127.0.0.1,::1

Add your Nagios server’s IP address to this list, separated by a comma:

allowed_hosts=127.0.0.1,::1,192.168.1.100

Replace 192.168.1.100 with the actual IP address of your Nagios monitoring server. NRPE will reject any connection from an IP not listed here.

Security rule: Never add 0.0.0.0 or a broad subnet like 192.168.1.0/24 here unless you have additional network-level access controls in place. Limit access to the exact IP of your Nagios server.

Verify the Server Port

Confirm the NRPE listening port is set to the default 5666:

server_port=5666

Review the Built-in Check Commands

Scroll down to the command definitions section. Ubuntu 24.04 ships NRPE with these defaults already defined:

command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200

Each command follows this pattern:

  • command[name] defines what Nagios calls when it sends a request.
  • -w sets the warning threshold.
  • -c sets the critical threshold.

You can adjust these thresholds to match your server’s normal operating profile.

Save and Close the File

Press CTRL+X, then Y, then Enter to save in nano.

Step 4: Allow Port 5666 Through the Ubuntu Firewall

If UFW (Uncomplicated Firewall) is active on your Ubuntu 24.04 server, you must open TCP port 5666 or NRPE connections from the Nagios server will be silently blocked.

First, check whether UFW is active:

sudo ufw status

If it shows Status: active, run the following to allow connections from the Nagios server only:

sudo ufw allow from 192.168.1.100 to any port 5666

Replace 192.168.1.100 with your Nagios server’s IP. This approach is more secure than opening port 5666 to the world.

If you prefer to open it globally (acceptable only in a trusted private network):

sudo ufw allow 5666/tcp

Reload UFW to apply the changes:

sudo ufw reload

Verify the rule is active:

sudo ufw status verbose

You should see a rule allowing port 5666 from your Nagios server’s IP address.

Step 5: Start and Enable the NRPE Daemon

Now start the NRPE service and configure it to launch automatically every time the server reboots.

sudo systemctl start nagios-nrpe-server
sudo systemctl enable nagios-nrpe-server

What each command does:

  • systemctl start launches the NRPE daemon immediately.
  • systemctl enable registers the service to start automatically on boot.

Verify the service is running correctly:

sudo systemctl status nagios-nrpe-server

Expected output:

● nagios-nrpe-server.service - Nagios Remote Plugin Executor
     Loaded: loaded (/lib/systemd/system/nagios-nrpe-server.service; enabled)
     Active: active (running) since ...
   Main PID: 3782 (nrpe)
...
nrpe[3782]: Starting up daemon
nrpe[3782]: Server listening on 0.0.0.0 port 5666.
nrpe[3782]: Listening for connections on port 5666

The key lines to confirm are Active: active (running) and Listening for connections on port 5666.

Step 6: Test the NRPE Connection from the Nagios Server

This step runs on the Nagios monitoring server, not the Ubuntu 24.04 client. Testing connectivity before adding the host to Nagios saves a lot of debugging time later.

On the Nagios server, install the check_nrpe plugin if it is not already present:

# For Debian/Ubuntu-based Nagios servers
sudo apt install nagios-nrpe-plugin -y

Now test the connection to the Ubuntu 24.04 NRPE client. Replace <Client_IP> with the Ubuntu server’s IP:

/usr/lib/nagios/plugins/check_nrpe -H <Client_IP>

Expected output:

NRPE v4.0.3

If you see the version number, the connection works. Now test a specific check command:

/usr/lib/nagios/plugins/check_nrpe -H <Client_IP> -c check_load

Expected output example:

OK - load average: 0.08, 0.03, 0.01|load1=0.080;15.000;30.000;0; load5=0.030;10.000;25.000;0;

This confirms that NRPE received the request, ran the check_load plugin locally on the Ubuntu 24.04 client, and returned the result to the Nagios server.

Step 7: Add Custom NRPE Check Commands

The default check commands cover basic metrics, but production environments often need more. Rather than editing nrpe.cfg directly, use the drop-in directory /etc/nagios/nrpe.d/. Files placed here survive package upgrades without overwriting your custom work.

Create a new custom configuration file:

sudo nano /etc/nagios/nrpe.d/custom_checks.cfg

Add custom check definitions. Here are practical examples:

# Monitor a specific partition separately
command[check_var]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /var

# Monitor swap usage
command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 40% -c 20%

# Check if a specific process is running (e.g., nginx)
command[check_nginx]=/usr/lib/nagios/plugins/check_procs -c 1: -w 3: -C nginx

Save the file, then restart NRPE to load the new definitions:

sudo systemctl restart nagios-nrpe-server

Test one of the new commands from the Nagios server:

/usr/lib/nagios/plugins/check_nrpe -H <Client_IP> -c check_swap

Step 8: Register the Ubuntu Host on the Nagios Server

With NRPE running and tested, add the Ubuntu 24.04 server as a monitored host in Nagios. All of the following commands run on the Nagios server.

Create a host configuration file for the new Ubuntu server:

sudo nano /usr/local/nagios/etc/servers/ubuntu24.cfg

Add the host and service definitions:

define host {
    use                  linux-server
    host_name            ubuntu24-client
    alias                Ubuntu 24.04 LTS Server
    address              192.168.1.50
    max_check_attempts   5
    check_period         24x7
    notification_interval 30
    notification_period  24x7
}

define service {
    use                  generic-service
    host_name            ubuntu24-client
    service_description  CPU Load
    check_command        check_nrpe!check_load
}

define service {
    use                  generic-service
    host_name            ubuntu24-client
    service_description  Disk Usage
    check_command        check_nrpe!check_disk
}

define service {
    use                  generic-service
    host_name            ubuntu24-client
    service_description  Current Users
    check_command        check_nrpe!check_users
}

define service {
    use                  generic-service
    host_name            ubuntu24-client
    service_description  Total Processes
    check_command        check_nrpe!check_total_procs
}

Replace 192.168.1.50 with the actual IP of your Ubuntu 24.04 client.

Before restarting Nagios, validate the configuration to catch any syntax errors:

sudo nagios -v /usr/local/nagios/etc/nagios.cfg

If the output ends with Things look okay, restart the Nagios service:

sudo systemctl restart nagios

Within a few minutes, the Ubuntu 24.04 host will appear in the Nagios web interface with active service checks running.

Hardening NRPE Security on Ubuntu 24.04

A running NRPE daemon is a network-accessible service, so locking it down is not optional in production. Follow these hardening steps after your initial setup.

Disable command argument passing. Find the dont_blame_nrpe directive in /etc/nagios/nrpe.cfg and confirm it is set to 0:

dont_blame_nrpe=0

Setting this to 1 allows the Nagios server to pass arbitrary arguments to NRPE commands, which opens a remote code execution risk. Keep it at 0 unless you have a specific, controlled use case.

Bind NRPE to a specific network interface. If your Ubuntu 24.04 server has multiple network interfaces, restrict NRPE to listen only on the private/management interface:

server_address=192.168.1.50

Keep packages updated. Regularly update both nagios-nrpe-server and nagios-plugins:

sudo apt update && sudo apt upgrade nagios-nrpe-server nagios-plugins -y

Run NRPE as an unprivileged user. The nagios system user is created automatically during installation and the NRPE daemon runs under it by default. Never modify the service to run as root.

Troubleshooting Common NRPE Problems on Ubuntu 24.04

Even with a clean installation, you may hit a few issues. Here are the most common ones and how to fix them.

Problem 1: Connection refused on port 5666

Cause: NRPE daemon is not running, or it is not listening on the expected port.

Fix:

sudo systemctl status nagios-nrpe-server
sudo systemctl start nagios-nrpe-server

Also verify NRPE is actually bound to port 5666:

sudo ss -tlnp | grep 5666

Problem 2: CHECK_NRPE: Error - Could not complete SSL handshake

Cause: The SSL/TLS version negotiation fails between the Nagios server and the NRPE client.

Fix: Add or update the ssl_version directive in /etc/nagios/nrpe.cfg:

ssl_version=TLSv1.2+

Then restart NRPE:

sudo systemctl restart nagios-nrpe-server

Problem 3: NRPE: Command 'check_disk' not defined

Cause: The command name called by Nagios does not match any command[name] definition in nrpe.cfg or the nrpe.d/ directory.

Fix: Open /etc/nagios/nrpe.cfg and verify the exact command name. Command names are case-sensitive.

Problem 4: Connection times out with no response

Cause: A firewall is blocking TCP port 5666 between the Nagios server and the Ubuntu client.

Fix:

sudo ufw status verbose
sudo ufw allow from <Nagios_Server_IP> to any port 5666
sudo ufw reload

Problem 5: NRPE service fails to start after a config edit

Cause: A syntax error was introduced into nrpe.cfg or a file in nrpe.d/.

Fix: Run NRPE manually in debug mode to surface the exact error:

sudo /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d

You can also check the system journal for detailed logs:

sudo journalctl -u nagios-nrpe-server -n 50

Congratulations! You have successfully installed NRPE. Thanks for using this tutorial for installing the Nagios Client (NRPE) on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Nagios website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a dedicated and highly skilled Linux Systems Administrator with over a decade of progressive experience in designing, deploying, and maintaining enterprise-grade Linux infrastructure. His professional journey began in the telecommunications industry, where early exposure to Unix-based operating systems ignited a deep and enduring passion for open-source technologies and server administration.​ Throughout his career, r00t has demonstrated exceptional proficiency in managing large-scale Linux environments, overseeing more than 300 servers across development, staging, and production platforms while consistently achieving 99.9% system uptime. He holds advanced competencies in Red Hat Enterprise Linux (RHEL), Debian, and Ubuntu distributions, complemented by hands-on expertise in automation tools such as Ansible, Terraform, Bash scripting, and Python.
Back to top button