DebianDebian Based

How To Install NRPE on Debian 12

Install NRPE on Debian 12

In this tutorial, we will show you how to install NRPE on Debian 12. Nagios is a powerful open-source monitoring system that allows you to keep a watchful eye on your IT infrastructure. One of its key features is the ability to monitor remote Linux hosts using the Nagios Remote Plugin Executor (NRPE).

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Nagios Remote Plugin Executor (NRPE) on Debian 12 (Bookworm).

Prerequisites

Before proceeding with the installation of NRPE on Debian 12, ensure you meet the following requirements:

  • A server running one of the following operating systems: Debian 12 (Bookworm).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • A user account with sudo privileges to execute administrative commands.

Install NRPE on Debian 12 Bookworm

Step 1. To begin the installation process, update your Debian 12 server’s package index by running the following command:

sudo apt update
sudo apt upgrade

Step 2. Installing NRPE on Debian 12.

Once the package index is updated, install the nagios-nrpe-server and nagios-plugins packages using the command:

sudo apt install nagios-nrpe-server nagios-plugins

The nagios-nrpe-server package contains the NRPE daemon, while the nagios-plugins package provides a collection of plugins that NRPE can execute to monitor various aspects of your system.

After the installation is complete, you can verify the NRPE version by running:

/usr/sbin/nrpe -V

This command will display the installed version of NRPE, confirming a successful installation.

Step 3. Configure NRPE.

With the NRPE packages installed, it’s time to configure the NRPE daemon. Open the NRPE configuration file /etc/nagios/nrpe.cfg using your preferred text editor with root privileges:

sudo nano /etc/nagios/nrpe.cfg

Locate the allowed_hosts directive and set it to the IP address of your Nagios server. This setting restricts which hosts can connect to the NRPE daemon. For example:

allowed_hosts=192.168.1.100

If you want to use a port other than the default 5666 for NRPE communication, uncomment the server_port directive and set it to your desired port number:

server_port=5666

Next, scroll down to the command definitions section. Here, you can specify the plugins that NRPE will execute when requested by the Nagios server. The format for command definitions is as follows:

command[command_name]=/path/to/plugin $ARG1$ $ARG2$

Replace command_name with a descriptive name for the command, /path/to/plugin with the actual path to the Nagios plugin, and $ARG1$, $ARG2$, etc., with any required arguments.

For example, to define a command that checks the CPU load, you can use:

command[check_load]=/usr/lib/nagios/plugins/check_load -w 5,4,3 -c 10,8,6

To allow NRPE to accept arguments in command definitions, set the dont_blame_nrpe directive to 1:

dont_blame_nrpe=1

Optionally, you can specify an alternate user and group for the NRPE daemon to run as using the nrpe_user and nrpe_group directives.

After configuring NRPE and opening the necessary firewall port, restart the NRPE daemon to apply the changes:

sudo systemctl restart nagios-nrpe-server

Verify that the NRPE daemon is running and listening on the configured port by using the command:

sudo ss -tulpn | grep nrpe

If you encounter any errors during the restart process, check the system logs (/var/log/syslog or journalctl -u nagios-nrpe-server) for detailed information and troubleshooting accordingly.

Step 4. Open Firewall Port.

To allow the Nagios server to communicate with the NRPE daemon on the remote Debian 12 host, you need to open the appropriate firewall port. By default, NRPE uses TCP port 5666.

If you’re using UFW (Uncomplicated Firewall), run the following command to allow incoming connections on port 5666:

sudo ufw allow 5666/tcp

If you’re using iptables, you can open the port with the command:

sudo iptables -A INPUT -p tcp --dport 5666 -j ACCEPT

Step 5. Configure Nagios Server.

With NRPE installed and configured on the remote Debian 12 host, it’s time to configure the Nagios server to utilize NRPE for monitoring.

On your Nagios server, define a new host entry for the Debian 12 server in the appropriate configuration file (e.g., /etc/nagios/conf.d/hosts.cfg):

define host {
use generic-host
host_name debian12-server
alias Debian 12 Server
address 192.168.1.200
check_command check_nrpe
}

Replace debian12-server with a descriptive name for your Debian 12 host, and update the address field with the server’s IP address.

Next, define the NRPE services you want to monitor on the remote host. Create a new service configuration file (e.g., /etc/nagios/conf.d/debian12-services.cfg) and add the desired service definitions. For example:

define service {
use generic-service
host_name debian12-server
service_description CPU Load
check_command check_nrpe!check_load
}

In this example, we define a service that checks the CPU load on the Debian 12 server using the check_load command defined in the NRPE configuration.

After defining the necessary host and service configurations, validate the Nagios configuration files for any syntax errors:

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

If no errors are reported, restart the Nagios daemon to apply the changes:

sudo systemctl restart nagios

Step 6. Test Remote Plugin Execution

To ensure that NRPE is functioning correctly and can execute plugins on the remote Debian 12 host, you can manually run check_nrpe commands from the Nagios server. Use the following command format:

/usr/lib/nagios/plugins/check_nrpe -H <remote_host> -c <command_name> -a <arguments>

Replace <remote_host> with the IP address or hostname of your Debian 12 server, <command_name> with the name of the command you want to execute (as defined in the NRPE configuration), and <arguments> with any required arguments for the command.

For example, to check the disk space on the remote host using the check_disk command with a warning threshold of 20% and a critical threshold of 10%, run:

/usr/lib/nagios/plugins/check_nrpe -H 192.168.1.200 -c check_disk -a "-w 20% -c 10%"

If the command executes successfully, you will see the plugin output and status. If there are any issues, review the Nagios and NRPE logs on both the Nagios server and the remote Debian 12 host for error messages and troubleshoot accordingly.

Remember that when you execute a command using check_nrpe, the actual plugin is executed by the NRPE daemon on the remote host, and the results are returned to the Nagios server.

Congratulations! You have successfully installed NRPE. Thanks for using this tutorial to install the latest version of the Nagios Remote Plugin Executor (NRPE) on Debian 12 Bookworm. 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 an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button