Install Nagios Core and Plugins on Linux: The Definitive Guide

As a CTO and Senior Linux System Administrator, I understand how vital a robust, scalable monitoring solution is for modern infrastructure. Nagios, ranked among the Top 10 Network Monitoring tools in 2023, delivers advanced visibility through its flexible plugin ecosystem. This guide offers a clear, best-practice approach to installing and configuring Nagios on CentOS, Rocky Linux, and AlmaLinux, empowering Linux professionals to detect issues proactively, minimize downtime, and maintain consistent service performance across enterprise-grade environments.

🤖 AI Overview:
To install Nagios plugins on Linux, download the official source package, install dependencies like build-essential and libssl-dev, then compile the code using ./configure, make, and make install. The compiled plugins are located in /usr/local/nagios/libexec/ and can be tested manually using the command line to ensure proper execution.

What Is Nagios Core?

Nagios Core is an open source monitoring engine that provides the foundation for building a comprehensive infrastructure monitoring system. It works by scheduling checks for various services and hosts, analyzing the results, and triggering alerts or recovery actions when predefined thresholds are breached.

Nagios is highly favored in enterprise environments due to its modular architecture, which separates the core processing logic from the actual monitoring tasks performed by plugins. This design provides flexibility, scalability, and support for custom integrations.

By deploying Nagios Core, system administrators gain real time visibility into system health, service availability, and performance bottlenecks. Whether you’re monitoring databases, web services, or distributed infrastructure, Nagios helps you proactively detect issues before they impact users or business operations.

Its reliability, community support, and extensibility make Nagios Core a trusted tool for Linux based monitoring across production environments.

Nagios vs. Nagios Plugins: Key Differences

Understanding the distinction between Nagios Core and Nagios Plugins is fundamental to building an effective monitoring setup.

  • Nagios Core acts as the orchestration engine. It handles scheduling, event processing, alerting, and managing the overall monitoring logic.
  • Nagios Plugins, on the other hand, are independent scripts or binaries that perform the actual checks such as verifying disk usage, CPU load, service uptime, or network latency.

Nagios Core doesn’t perform any monitoring by itself. Instead, it delegates these tasks to plugins and processes the returned results. This separation of concerns allows for significant flexibility: you can use official plugins, write your own in Bash, Python, or Perl, and integrate third party tools with ease.

Supported Linux Distributions for Nagios

Nagios Core is designed to be distribution agnostic, but successful deployment often depends on package availability, dependency management, and system conventions.

Here are the major Linux distributions where Nagios Core is tested and commonly used:

Linux DistributionResultNotes
Ubuntu
v20 - v22 - v24
Fully compatible. Minor adjustments may be needed (e.g., install libssl-dev). On 24.04, NRPE may require manual service restart.
Debian
v10 - v11 - v12
Stable and fully supported. Plugins compile cleanly using default repositories. Ideal for production environments.
CentOS
v7 - v8
Compatible with standard yum packages. May require enabling EPEL repository for development tools.
Fedora
v36 - v40
⚠️Partially compatible. Requires manual installation of gcc, make, and other dev tools. Some plugins may show unexpected output (e.g., disk paths).
Arch Linux⚠️Compatible but requires manual setup. Rolling release model may introduce breaking changes. Not recommended for stable monitoring environments.
Kali Linux⚠️Technically compatible, but not optimized for long term Nagios deployment. Suitable only for testing or labs.
Rocky Linux
v8 - v9
Verified compatibility. Clean installation using dnf groupinstall "Development Tools" and EPEL.
AlmaLinux
v8 - v9
Similar to Rocky. Stable platform for Nagios plugins with enterprise grade behavior and compatibility.

Each distribution may require slight modifications to prerequisites, permissions, or service configurations. Our installation guide provides tailored instructions to ensure compatibility across all supported platforms.

How to Install Nagios on Linux

Now that you’re familiar with what Nagios is and why it’s a critical component in infrastructure monitoring, let’s walk through a structured installation process tailored for modern Linux environments.
Whether you’re deploying on CentOS, Rocky Linux, or AlmaLinux, the core steps remain consistent across distributions. Here’s what you’ll need to do:
Follow These 7 Steps to Install Nagios on Any Major Linux Distribution:

  1. Update your Linux system packages and repositories.
  2. Install required dependencies, including build tools and libraries.
  3. Create the Nagios user and command group for permissions.
  4. Download and compile the Nagios Core source code.
  5. Configure the web interface and set up user authentication.
  6. Install Nagios Plugins to enable service checks.
  7. Set up NRPE for optional remote monitoring if needed.

These steps form the foundation of any successful Nagios deployment. In the following sections, we provide detailed, distro specific guidance for Ubuntu, CentOS, Rocky Linux, AlmaLinux, Debian, and more. ensuring smooth installation, configuration, and verification.

Installing Nagios on Ubuntu

Before installing Nagios on Ubuntu, it’s essential to prepare the system with the correct dependencies and environment settings. Without these prerequisites, the installation process may fail or result in incomplete configurations.

Start by updating your system’s package index to ensure you’re using the latest repositories:

sudo apt update
Then, install the core packages required to compile Nagios and its plugins:
sudo apt install -y build-essential libssl-dev libgd-dev libperl-dev \
gettext autoconf automake libmysqlclient-dev apache2 php \
libapache2-mod-php unzip wget curl
These packages include essential build tools, graphic libraries (used in graphs and web UI), and web server components needed for the Nagios web interface.

Add Dedicated Nagios User and Group

To maintain system security and process isolation, create a new user and group for Nagios:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

This setup allows Nagios to execute monitoring commands securely and communicate with Apache via shared group permissions.

Once these steps are complete, your Ubuntu system is fully prepared to install and run Nagios Core. The same principles apply when setting up on other Debian based distributions such as Debian itself or Linux Mint.

Install Nagios Core on Ubuntu (Recommended: Ubuntu 24.04)

Ubuntu 24.04 is currently one of the most stable and up to date environments for running Nagios. With long term support and a robust package ecosystem, it ensures smooth installation and maintenance of monitoring tools.

1. Download and Extract Nagios Core

Begin by downloading the latest stable release of Nagios Core:

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
tar -zxvf nagios-4.4.14.tar.gz
cd nagios-4.4.14

2. Compile and Install Nagios

Run the configuration script to prepare the build:

./configure --with-command-group=nagcmd
make all

Then install Nagios Core and its components:

sudo make install
sudo make install-groups-users
sudo make install-commandmode
sudo make install-config

3. Install and Configure Web Interface

To enable the Nagios web UI:

sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enable Apache modules and start the service:

sudo a2enmod cgi
sudo systemctl restart apache2
sudo systemctl enable apache2

4. Adjust Firewall (Optional)

If ufw is enabled, allow HTTP access:

sudo ufw allow Apache

At this stage, Nagios Core should be accessible via http://your-server-ip/nagios. Use the login credentials you set with htpasswd to access the interface.

Ubuntu 24.04 provides excellent compatibility, but ensure all dependencies such as libgd-dev and libssl-dev are installed beforehand. You’re now ready to extend your setup by adding Nagios Plugins.

Install Nagios Plugins on Ubuntu

Nagios Core provides the engine but it’s the plugins that perform actual checks. These plugins are essential for monitoring disk space, CPU load, network status, and hundreds of other metrics. On Ubuntu, compiling the official Nagios Plugins from source ensures full compatibility and flexibility.

1. Download the Official Plugin Package

Begin by retrieving the latest release from the Nagios Plugins project:

wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
tar -zxvf release-2.3.3.tar.gz
cd nagios-plugins-release-2.3.3

2. Install Required Dependencies

Make sure development libraries are in place:

sudo apt update
sudo apt install -y autoconf gcc libmcrypt-dev make libssl-dev wget unzip libgd-dev libperl-dev

3. Compile and Install the Plugins

Use the standard configure, make, and make install pattern:

./tools/setup
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

This installs the plugins into the /usr/local/nagios/libexec/ directory by default.

4. Test the Plugins

You can verify plugin functionality by running checks manually from the terminal:

/usr/local/nagios/libexec/check_load -w 5,4,3 -c 10,6,4

This example tests system load averages and returns appropriate exit codes for OK, Warning, or Critical thresholds.

The plugin system is designed to be extensible, allowing you to write custom checks in Bash, Python, or Perl. Once plugins are installed and tested, your Nagios instance becomes a powerful real time monitoring solution.

Install NRPE on Ubuntu

To enable remote monitoring from your Nagios server, you’ll need to install the NRPE (Nagios Remote Plugin Executor) agent on your Ubuntu based clients. NRPE allows Nagios Core to execute checks on remote systems, expanding visibility beyond just the monitoring host.

1. Install the NRPE Server Package
First, update your package index and install the NRPE server along with Nagios plugins on the remote system:

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

2. Configure NRPE
Edit the NRPE configuration file to allow connections from your Nagios server:

sudo nano /etc/nagios/nrpe.cfg

Locate the line:

allowed_hosts=127.0.0.1

And replace it with:

allowed_hosts=127.0.0.1,<your-nagios-server-ip>

3. Restart NRPE Service
Apply your changes by restarting the NRPE service:

sudo systemctl restart nagios-nrpe-server
sudo systemctl enable nagios-nrpe-server

4. Verify NRPE is Listening
Check if the NRPE daemon is listening on port 5666:

sudo netstat -an | grep 5666

Or use:

sudo ss -tnlp | grep nrpe

5. Test Remote Check from Nagios Server
On the Nagios server, test communication with the client:

/usr/local/nagios/libexec/check_nrpe -H <client-ip>

A successful response confirms that NRPE is properly set up and ready to receive remote check requests.

Installing Nagios on Debian

Before you install Nagios Core on a Debian based system, you need to ensure the system is equipped with the necessary development libraries and user permissions. These prerequisites prepare the environment for compiling both Nagios Core and its official plugins without errors.

1. Update Your Package Index

Begin by refreshing the local package index to ensure you fetch the latest versions:

sudo apt update && sudo apt upgrade -y

2. Install Required Build Tools and Libraries

Nagios depends on a number of development headers and libraries. Install them using:

sudo apt install -y build-essential libssl-dev libgd-dev libperl-dev libpng-dev \
gettext autoconf automake unzip wget apache2 php libapache2-mod-php

These packages are required for compiling Nagios Core, Nagios Plugins, and integrating the web interface with Apache.

3. Add Nagios User and Group

Nagios needs a dedicated system user and group to run securely:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

The nagcmd group controls permissions for external commands and is required by both Nagios and Apache.

4. Configure Apache for Web Interface (Optional but Recommended)

If you plan to use the Nagios web UI, Apache and PHP must be enabled and running:

sudo systemctl enable apache2
sudo systemctl start apache2

You’ll configure Apache’s virtual host for Nagios in a later step, but having it running now ensures a smooth setup experience.

Install Nagios Core on Debian (Recommended: Debian 12)

Once the prerequisites are in place, you can proceed with compiling and installing Nagios Core on Debian 12. This process involves downloading the source code, configuring the build environment, and installing the necessary components.

1. Download the Nagios Core Source Package

Visit the official Nagios website or use the following command to get the latest stable version:

cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
tar -xzf nagios-4.4.14.tar.gz
cd nagios-4.4.14

2. Configure and Compile

Set up the build with the correct permissions group (nagcmd) and compile the binaries:

./configure --with-command-group=nagcmd
make all

This builds the Nagios daemon, CGIs, and web configuration files.

3. Install Core Components

Install the Nagios binaries and supporting files:

sudo make install
sudo make install-groups-users
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config

These commands install systemd service files, initial configuration files, and permissions required to manage Nagios securely.

4. Configure Web Interface

Install the web interface integration with Apache:

sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo systemctl restart apache2

💡 Tip:
Replace nagiosadmin with your preferred admin username. This account is required to access the web UI.

5. Enable and Start the Nagios Service

Finally, enable the Nagios service to start on boot and start it manually for the first time:

sudo systemctl enable nagios
sudo systemctl start nagios

At this point, you should be able to access the Nagios web interface via:
http://<your-server-ip>/nagios

Install Nagios Plugins on Debian

Nagios Core by itself provides the engine for scheduling and alerting, but it relies on plugins to perform actual checks. Installing the official Nagios plugins ensures full monitoring capability for disk space, services, CPU usage, network latency, and more.

1. Download the Official Nagios Plugins Package

Navigate to your temporary directory and download the latest stable release of Nagios plugins:

cd /tmp
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.3.3/nagios-plugins-2.3.3.tar.gz
tar -zxvf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3

2. Compile and Install

Configure the source code with the appropriate Nagios installation prefix, then build and install:

./configure --prefix=/usr/local/nagios
make
sudo make install

This step compiles all standard plugin binaries and places them in the default execution directory:
/usr/local/nagios/libexec/

3. Verify Plugin Installation

Check that the core plugins are available by listing the contents:

ls /usr/local/nagios/libexec/

You should see a set of executables like check_http, check_disk, check_load, etc.

You can manually test any plugin by executing it from the command line. For example:

/usr/local/nagios/libexec/check_load -w 5,4,3 -c 10,6,4

This command checks the system load average and returns an exit code along with a message, which Nagios uses for alerting.

Install NRPE on Debian

NRPE (Nagios Remote Plugin Executor) allows the Nagios server to perform remote checks on other Linux machines. This setup is essential for distributed monitoring in multi node environments.

1. Install Required Packages
On the remote Debian system, update the package index and install NRPE along with the standard Nagios plugins:

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

2. Configure NRPE Access
Open the configuration file and add the IP address of your Nagios server to allow connections:

sudo nano /etc/nagios/nrpe.cfg

Find the line:

sudo nano /etc/nagios/nrpe.cfg

Replace it with:

allowed_hosts=127.0.0.1,<nagios-server-ip>

3. Restart the NRPE Service

Apply the changes and ensure the service starts on boot:

sudo systemctl restart nagios-nrpe-server
sudo systemctl enable nagios-nrpe-server

4. Verify NRPE Operation

To confirm NRPE is listening on port 5666, run:

sudo ss -tuln | grep 5666

5. Test from Nagios Server

From the Nagios server, test connectivity to the Debian client:

/usr/local/nagios/libexec/check_nrpe -H <debian-client-ip>

A successful response indicates that the NRPE agent is correctly installed and ready to run remote plugin checks.

Installing Nagios on CentOS

⚠️ Important Notice Before Installing
While this guide provides full installation steps for CentOS, we do not recommend CentOS for new deployments due to its discontinued support model and lack of long term stability. If you are required to use CentOS for compatibility or legacy reasons:

✅ The most stable version for Nagios is CentOS 7 (supported until June 2024).

⚠️ CentOS Stream 9 is technically usable, but as a rolling release, it may introduce breaking changes.

✅ Recommend:
For production environments, we strongly recommend switching to Rocky Linux 9 or AlmaLinux 9 both are RHEL compatible (Red Hat Enterprise Linux), community supported, and ideal for long term use.

Before you compile and install Nagios Core on CentOS, it’s essential to prepare the system with the required packages, user permissions, and dependencies. These steps apply to both CentOS 7 and 8 and are compatible with downstream distributions such as Rocky Linux and AlmaLinux.

1. Update the System and Enable EPEL

Start by updating the system repositories and enabling the EPEL (Extra Packages for Enterprise Linux) repository to access essential development tools:

sudo yum update -y
sudo yum install epel-release -y

2. Install Required Packages

Install the full suite of development tools and libraries needed to compile Nagios and its plugins:

sudo yum groupinstall "Development Tools" -y
sudo yum install gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix make openssl-devel -y

These packages provide compilers, web server support, graphics libraries for status map generation, and essential SSL dependencies for plugin communication.

3. Create the Nagios User and Command Group

Nagios runs under its own system user and uses a command group (nagcmd) to allow the web interface and external agents to submit monitoring commands:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd apache

Apache (httpd) must also be added to the nagcmd group to control services and schedule checks via the web UI.

Install Nagios Core on CentOS (Not Recommended)

Although CentOS 7 remains a functional environment for installing Nagios Core, it is not the ideal choice for long term monitoring infrastructure. However, if you’re operating in a legacy environment or temporarily bound to CentOS, you can still install Nagios Core by following these steps:

1. Install Required Dependencies

Use yum to install the necessary development packages:

sudo yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix

2. Create Nagios User and Group

Set up user accounts and permissions for Nagios:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd apache

3. Download and Extract Nagios Source

Get the latest stable release of Nagios Core:

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
tar -zxvf nagios-4.4.14.tar.gz
cd nagios-4.4.14

4. Compile and Install Nagios Core

./configure --with-command-group=nagcmd
make all
sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo make install-webconf

5. Configure Apache and Start Nagios

Enable HTTP basic auth and start the web server:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo systemctl enable httpd
sudo systemctl start httpd
sudo systemctl start nagios

️✍️ Note:
CentOS 7 uses older libraries, so some plugin features may require manual configuration or package backports. Always validate your installation with nagios -v and monitor for missing dependencies.

✅ Recommend:
Consider migrating to Rocky Linux 9 or AlmaLinux 9 for more secure and stable support in future deployments.

Install NRPE on CentOS

NRPE (Nagios Remote Plugin Executor) lets your Nagios server execute plugins remotely on CentOS based systems. This setup expands your monitoring capabilities to include detailed checks on CPU usage, disk space, memory load, and more.

Follow these straightforward steps to install and configure NRPE on CentOS 7 or CentOS Stream:

1. Install EPEL Repository and NRPE

Ensure you have the EPEL repository enabled, then install NRPE and standard Nagios plugins:

sudo yum install epel-release -y
sudo yum install nrpe nagios-plugins-all openssl -y

2. Configure NRPE Access

Edit the NRPE configuration to specify your Nagios server’s IP:

sudo vi /etc/nagios/nrpe.cfg

Find the line:

allowed_hosts=127.0.0.1

Replace it with:

allowed_hosts=127.0.0.1,<your-nagios-server-ip>

3. Enable and Start NRPE Service

Start the NRPE daemon and set it to launch automatically on boot:

sudo systemctl start nrpe
sudo systemctl enable nrpe

4. Open Firewall Port (Optional but Recommended)

If the firewall is enabled, ensure it allows NRPE traffic (port 5666):

sudo firewall-cmd --permanent --zone=public --add-port=5666/tcp
sudo firewall-cmd --reload

5. Verify NRPE Installation

On your Nagios server, test the connection to the CentOS client using:

/usr/local/nagios/libexec/check_nrpe -H <centos-client-ip>

If configured correctly, you’ll see the NRPE version number returned, confirming the setup is ready for remote monitoring.

Installing Nagios on Rocky Linux & AlmaLinux

Before proceeding with the installation of Nagios on Rocky Linux or AlmaLinux, ensure your system meets the necessary requirements for compiling from source and running a stable monitoring stack.

These two distributions are binary compatible with RHEL and provide long term support, making them ideal choices for deploying monitoring tools like Nagios.

1. System Preparation

Make sure your system is up to date and has access to the EPEL repository:

sudo dnf update -y
sudo dnf install epel-release -y

2. Install Required Development Tools and Libraries

Nagios and its plugins need compilers, build tools, and SSL libraries to compile properly:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix openssl-devel net-snmp net-snmp-utils

💡 Tip:
These dependencies are required for both Nagios Core and the official plugin set. If you plan to monitor remote nodes via NRPE, keep xinetd and nrpe packages in mind during plugin configuration.

3. Create Dedicated Nagios User and Group

Creating a separate user ensures permission isolation for the Nagios daemon:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd apache

4. Firewall and SELinux Notes

  • Ensure HTTP traffic (port 80) is allowed:
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
  • If SELinux is enabled, it may interfere with the Nagios web interface and command execution. Temporarily disable it or adjust contexts accordingly:
sudo setenforce 0

🔒 Security Tip:
Disabling SELinux is not recommended in production. Instead, consider adjusting SELinux policies or running Nagios in a containerized environment with AppArmor or Podman.

Once these prerequisites are satisfied, you’re ready to download, compile, and configure Nagios Core and Plugins on a solid enterprise grade platform.

Install Nagios Core on Rocky Linux & AlmaLinux

With the system prepared, you can now proceed to install Nagios Core from source. These instructions are validated on both Rocky Linux 9 or AlmaLinux 9, ensuring compatibility with RHEL based environments.

1. Download Nagios Core Source

Navigate to the source directory and download the latest stable release:

cd /usr/src/
sudo wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
sudo tar -zxvf nagios-4.4.14.tar.gz
cd nagios-4.4.14

2. Compile and Install Nagios

Configure the build system and compile Nagios with the correct command group:

./configure --with-command-group=nagcmd
make all
sudo make install

3. Install Nagios Components

Install the essential binaries, configuration files, and the system service:

sudo make install-groups-users
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config

4. Configure Web Interface

Install the Nagios web interface and enable HTTP authentication:

sudo make install-webconf
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart and enable Apache:

sudo systemctl restart httpd
sudo systemctl enable httpd

5. Start Nagios Service

Finally, enable and start the Nagios service:

sudo systemctl enable nagios
sudo systemctl start nagios

Once complete, you can verify your Nagios Core installation by visiting:

http://<your_server_ip>/nagios

Use the credentials created earlier (nagiosadmin) to log in.

🔒 Security Tip:
Ensure the firewall is configured to allow port 80, and consider using HTTPS and basic hardening techniques before exposing the interface to production environments.

Nagios Core is now installed and ready to be extended with official plugins and remote execution tools like NRPE.

Install Nagios Plugins on Rocky Linux & AlmaLinux

After setting up Nagios Core, the next step is to install the official Nagios Plugins package. These plugins are essential for executing health checks on system resources, services, and network components.

1. Install Required Dependencies

Start by installing the packages needed to build the plugins from source:

sudo dnf install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release perl-Net-SNMP

2. Download and Extract Plugin Source

Download the latest version of the Nagios Plugins from the official repository:

cd /usr/src/
sudo wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
sudo tar zxf nagios-plugins.tar.gz
cd nagios-plugins-release-2.3.3

3. Compile and Install the Plugins

Run the standard build steps to install the plugins:

./tools/setup
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

Once installed, the plugins will be located in:

/usr/local/nagios/libexec/

4. Verify Plugin Functionality

You can manually test a plugin to confirm it works as expected:

/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1

A correct output such as DISK OK or WARNING based on your disk usage indicates successful installation.

⚠️ Tip:
Make sure that the nagios service has appropriate permissions to execute these plugins and that SELinux or AppArmor policies (if active) do not block plugin execution.

With the official plugins in place, your Nagios installation is now capable of performing both local and remote checks. You can proceed to define services, hosts, and advanced notification rules within your Nagios configuration.

Install NRPE on Rocky Linux & AlmaLinux

NRPE (Nagios Remote Plugin Executor) is essential for performing detailed remote monitoring checks using Nagios. Rocky Linux and AlmaLinux, both RHEL compatible distributions, provide a stable environment for running NRPE seamlessly.

1. Enable EPEL Repository and Install NRPE

First, enable the EPEL repository to access necessary packages, then install NRPE and Nagios plugins:

sudo dnf install epel-release -y
sudo dnf install nrpe nagios-plugins-all openssl -y

2. Configure NRPE

Edit the main NRPE configuration file to allow the Nagios server to connect:

sudo vi /etc/nagios/nrpe.cfg

Find the line:

allowed_hosts=127.0.0.1

Replace it with:

allowed_hosts=127.0.0.1,<nagios-server-ip>

Replace <nagios-server-ip> with your Nagios server’s actual IP address.

3. Start and Enable NRPE Service

Start NRPE immediately and enable it to run at boot:

sudo systemctl start nrpe
sudo systemctl enable nrpe

4. Open Firewall Port

Ensure the NRPE service port (5666) is accessible through the firewall:

sudo firewall-cmd --permanent --zone=public --add-port=5666/tcp
sudo firewall-cmd --reload

5. Verify NRPE Setup

From your Nagios server, confirm NRPE is running correctly on Rocky or AlmaLinux by executing:

/usr/local/nagios/libexec/check_nrpe -H <rocky-alma-ip>

A successful setup will return the NRPE version number, confirming your installation is ready for remote monitoring.

Installing Nagios on Arch Linux

Arch Linux is a flexible, minimalist, and rolling release distribution intended for experienced users. While it’s not typically used in production environments, Arch provides a clean environment ideal for testing Nagios in highly customized setups. Before installing Nagios Core and its plugins on Arch, ensure your system meets the following prerequisites:

1. Update the System

Keep your system current by updating all installed packages:

sudo pacman -Syu

2. Install Required Development Tools and Libraries

Nagios must be compiled from source, so you’ll need base development tools and several supporting libraries:

sudo pacman -S --needed base-devel openssl gd perl wget unzip apache php net-snmp

✅ Recommend:
Some optional dependencies like fping or mailx may also be useful depending on your plugin configuration. These can be installed later if needed.

3. Create the Required User and Groups

Nagios should run under its own user for security and process isolation:

sudo useradd -m -s /bin/bash nagios
sudo groupadd nagcmd
sudo usermod -aG nagcmd nagios
sudo usermod -aG nagcmd http  # 'http' is the default Apache user on Arch Linux

4. Enable and Start Apache Web Server

Nagios requires a web interface, which is served via Apache:

sudo systemctl enable httpd
sudo systemctl start httpd

5. Firewall Rules (Optional)

If you’re using iptables or firewalld, open the HTTP port:

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

After completing these prerequisites, you’re ready to compile and install Nagios Core on Arch Linux. While Arch evolves rapidly as a rolling release distribution, the steps provided here are aligned with current standards. For deeper customization or edge case scenarios, the Arch Wiki remains a valuable reference.

Install Nagios Core on Arch Linux

Installing Nagios Core on Arch Linux involves compiling from source, which gives you maximum flexibility and transparency. Make sure all prerequisites are already configured as outlined in the previous section.

1. Download the Latest Nagios Source

Navigate to your source directory and fetch the latest stable release:

cd /usr/src/
sudo wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
sudo tar -xzf nagios-4.4.14.tar.gz
cd nagios-4.4.14

2. Configure Build Options

Run the configuration script and set the appropriate group:

./configure --with-command-group=nagcmd

3. Compile and Install Nagios Core

Build and install Nagios:

make all
sudo make install
sudo make install-init
sudo make install-commandmode
sudo make install-config
sudo make install-webconf

4. Set Up Web Interface Access

Create a user for web login and protect the web directory:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

5. Enable and Start Required Services

Start and enable Apache and Nagios services:

sudo systemctl enable httpd
sudo systemctl start httpd
sudo systemctl enable nagios
sudo systemctl start nagios

6. Verify Installation

Open your browser and visit:

http://<your-arch-ip>/nagios

Login with the user created above to access the Nagios Core web interface. If everything is correctly installed, you’ll see the Nagios dashboard and default monitoring configuration.

⚠️ Tip:
If the dashboard fails to load, check Apache logs in /var/log/httpd/ and Nagios logs in /usr/local/nagios/var/.

With Nagios Core now running on Arch Linux, you’re ready to install and configure plugins to extend its monitoring capabilities.

Install Nagios Plugins on Arch Linux

Nagios Core relies on plugins to perform actual checks on system metrics and services. On Arch Linux, you can either install official plugins directly from the AUR or build them manually from source for full control.

Option 1: Install via nagios-plugins Package (Recommended for Simplicity)

The Arch Community repository includes a maintained nagios-plugins package:

sudo pacman -Syu nagios-plugins

This package installs the official set of basic checks to /usr/lib/nagios/plugins/, which Nagios Core will use by default.

Option 2: Build Plugins from Source (For Customization)

If you prefer to build the latest version manually or require plugin customization, follow these steps:

1. Download Nagios Plugins Source

cd /usr/src/
sudo wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz -O nagios-plugins.tar.gz
sudo tar -xzf nagios-plugins.tar.gz
cd nagios-plugins-release-2.3.3

2. Compile and Install Plugins

./tools/setup
./configure --prefix=/usr/local/nagios
make
sudo make install

Plugins will be placed under /usr/local/nagios/libexec/.

3. Verify Plugin Installation

Run a sample plugin to confirm it’s working:

/usr/local/nagios/libexec/check_load -w 5.0,4.0,3.0 -c 10.0,6.0,4.0

If the command outputs “OK” or “WARNING” along with the system load metrics, the plugin is functioning correctly.

With plugins in place, your Arch based Nagios setup is now capable of performing meaningful monitoring tasks. Next, you can proceed to define host and service configurations based on your infrastructure needs.

Installing Nagios on Kali Linux

Kali Linux, being a penetration testing and security auditing distribution based on Debian, is not typically optimized for infrastructure monitoring tasks. However, if you’re using Kali for lab simulations, training, or secure system monitoring, you can still install Nagios though some manual package adjustments may be needed.

Before installing Nagios Core or its plugins, ensure that your system is up to date and has the essential development tools required for compiling from source:

1. Update Package Index

sudo apt update && sudo apt upgrade -y

2. Install Required Dependencies

Nagios requires several libraries and utilities to compile and function properly. Install them using:

sudo apt install -y build-essential libssl-dev libgd-dev libperl-dev gettext \
autoconf automake unzip apache2 php libapache2-mod-php \
wget curl ufw libmcrypt-dev libtool lsb-release

✍️Note:
In some cases, Kali may have restricted or rolling updates that conflict with Nagios’s dependency versions. Be prepared to troubleshoot or pin packages if conflicts arise.

3. Create Nagios User and Group

For a secure installation, Nagios should run under its own user:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Once your Kali Linux system has the necessary tools and users configured, you’ll be ready to compile and install Nagios Core. While Kali isn’t recommended for production monitoring, it remains suitable for learning

Install Nagios Core on Kali Linux

While Kali Linux is not a typical production environment, it is still fully capable of running Nagios Core for learning, testing, or isolated monitoring scenarios. Follow these steps to install Nagios Core on Kali:

1. Update the system and install dependencies:

sudo apt update && sudo apt upgrade -y
sudo apt install -y autoconf gcc make apache2 php libapache2-mod-php \
libgd-dev libmcrypt-dev libssl-dev bc gawk dc build-essential snmp \
libnet-snmp-perl gettext libpq-dev

2. Create Nagios user and group:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

3. Download and compile Nagios Core:

cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.14.tar.gz
tar -xvzf nagios-4.4.14.tar.gz
cd nagios-4.4.14
./configure --with-command-group=nagcmd
make all
sudo make install

4. Install Nagios web interface and default configs:

sudo make install-groups-users
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconf

5. Configure Apache and create web login:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo systemctl enable apache2 && sudo systemctl start apache2

6. Start Nagios service:

sudo systemctl start nagios

Once the installation is complete, you can access the Nagios web dashboard by navigating to:

http://<your-kali-ip-address>/nagios

💡 Tip:
Because Kali receives rolling updates frequently, be sure to validate compatibility with your current packages. Use the Nagios logs and nagios -v config validation to troubleshoot installation issues.

Install Nagios Plugins on Kali Linux

With Nagios Core up and running on Kali Linux, the next step is to install the official Nagios Plugins. These plugins enable actual checks and extend the functionality of the Nagios monitoring engine. Here’s how to do it:

1. Install required dependencies:

sudo apt update
sudo apt install -y build-essential autoconf libssl-dev libmcrypt-dev \
libgd-dev libtool net-snmp libnet-snmp-perl gettext

2. Download and extract Nagios Plugins source:

cd /tmp
wget https://github.com/nagios-plugins/nagios-plugins/archive/release-2.3.3.tar.gz
tar -xvzf release-2.3.3.tar.gz
cd nagios-plugins-release-2.3.3

3. Compile and install the plugins:

./tools/setup
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install

4. Verify plugin installation:

You can run a test plugin to confirm proper setup:

/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

💡 Tip:
Nagios plugins reside in /usr/local/nagios/libexec/. You can create your own Bash or Python plugins in this directory or extend monitoring with community contributed scripts.

Once installed, your Kali Linux setup is ready to perform real time checks using Nagios Plugins. Although Kali is not ideal for production use, this configuration is useful for test environments or educational scenarios.

Install NRPE on Kali Linux

Although Kali Linux is primarily designed for security testing and penetration assessments, it can still serve effectively as a Nagios remote monitoring client using the Nagios Remote Plugin Executor (NRPE). Follow these steps to configure NRPE on your Kali system.

1. Update System and Install Required Packages

Update your repositories and install NRPE along with Nagios plugins:

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

2. Configure NRPE to Allow Nagios Server Access

Edit the NRPE configuration file to permit your Nagios server IP to communicate:

sudo nano /etc/nagios/nrpe.cfg

Modify the following line:

allowed_hosts=127.0.0.1

Replace it with your Nagios server IP:

allowed_hosts=127.0.0.1,<nagios-server-ip>

3. Restart and Enable NRPE Service

Ensure NRPE is started and set to launch automatically upon system boot:

sudo systemctl restart nagios-nrpe-server
sudo systemctl enable nagios-nrpe-server

4. Verify NRPE Operation

On your Nagios server, verify NRPE connectivity by running:

/usr/local/nagios/libexec/check_nrpe -H <kali-client-ip>

A successful setup returns the NRPE version, confirming that remote plugin execution is correctly configured.

Troubleshoot Common Errors

While installing and configuring Nagios Core and plugins, you may encounter certain common issues. Here’s a systematic approach to diagnosing and resolving these errors efficiently.

1. Nagios Configuration Errors

If Nagios doesn’t start or throws configuration errors, verify your configuration files using:

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

Review the output carefully Nagios typically pinpoints the line causing the issue, making troubleshooting straightforward.

2. Nagios Web Interface Unavailable

If the web interface doesn’t load or returns an error:

Verify Apache (HTTPD) service status:

sudo systemctl status apache2 # Debian/Ubuntu
sudo systemctl status httpd # CentOS/Rocky/Alma

Check firewall rules:

sudo ufw status
sudo firewall-cmd --list-all

Ensure Apache modules are correctly enabled (CGI and PHP):

sudo a2enmod cgi
sudo systemctl restart apache2

3. NRPE Connection Refused or Timeout

If remote checks via NRPE fail:

Check if NRPE is listening on port 5666:

sudo netstat -an | grep 5666

Verify the firewall allows incoming connections on port 5666:

sudo ufw allow 5666/tcp # Ubuntu/Debian
sudo firewall-cmd --add-port=5666/tcp --permanent # CentOS/Rocky
sudo firewall-cmd --reload

Ensure the allowed_hosts parameter in /etc/nagios/nrpe.cfg includes your Nagios server IP.

4. Plugin ‘command not found’ or Missing

If Nagios reports a plugin as missing or returns “command not found”:

Check plugin installation directory:

ls /usr/local/nagios/libexec/

Ensure plugins have proper permissions:

sudo chown nagios:nagios /usr/local/nagios/libexec/*
sudo chmod +x /usr/local/nagios/libexec/*

5. SELinux or AppArmor Issues

If you use SELinux or AppArmor and encounter permissions issues, consider temporarily disabling to diagnose:

Temporarily disable SELinux (CentOS, Rocky, AlmaLinux):

sudo setenforce 0

Check SELinux status:

sestatus

For AppArmor (Ubuntu/Debian), inspect relevant profiles or temporarily disable problematic profiles.

⚠️ Security Tip:
Disable SELinux or AppArmor temporarily only for troubleshooting purposes. Always re enable and adjust policy rules afterward.

By systematically checking each of these common scenarios, you can effectively resolve most installation or operational issues encountered with Nagios.

FAQ

After installing Nagios Core, download the official Nagios Plugins source package, install dependencies like build-essential and libssl-dev, then compile and install them using ./configure, make, and make install.

Yes. Rocky Linux and AlmaLinux are RHEL compatible and provide long-term stability, making them well-suited for running Nagios Core and its plugins in production grade monitoring environments.

Configure the Nagios web interface by setting up HTTP authentication with htpasswd, enabling necessary Apache modules, and applying strong passwords. Additionally, consider using HTTPS and properly configuring SELinux or AppArmor profiles.

Install the NRPE package on your remote systems, configure the allowed_hosts parameter to include your Nagios server’s IP address, and test communication with the check_nrpe plugin to verify proper setup.

Check configuration files with nagios -v, verify Apache and firewall settings, ensure all required packages are installed, and review Nagios and web server logs for detailed error messages to diagnose issues effectively.

Nagios is an open-source monitoring engine that checks the availability, performance, and uptime of your servers and applications. Its plugins provide customizable monitoring capabilities.

The standard directory is /usr/local/nagios/libexec/ to maintain consistency with Nagios core installations.

Run plugins manually from the command line and check for appropriate exit codes and output.

NRPE allows the Nagios server to execute checks on remote hosts. The NRPE agent must be installed and configured on the remote system, and the server must be allowed in nrpe.cfg

Yes. Nagios plugins are widely compatible and can be used with tools like Icinga, Zabbix (via script execution), and custom monitoring setups that interpret standard plugin output.

Conclusion

In this article, you learned How to Install Nagios on CentOS, Rocky Linux and AlmaLinux. From now on you can enjoy the continuous monitoring of your system to benefit from constant detecting, reporting, and responding to risks and events within an IT system. Manual monitoring is no longer necessary thanks to Nagios. Additionally, Nagios centralizes and standardizes monitoring for all environments, gadgets, and systems.
If you follow the above steps of each part properly, you can smoothly install Nagios on your operating system without any errors but do not hesitate to contact us if you encounter any problems. Our technical support team will try their best to solve your problems.

Leave a Reply

Your email address will not be published. Required fields are marked.