IT administrators must be proactive rather than reactive. Catching infrastructure problems early — before they cascade into extended outages or data loss — is one of the most valuable skills an ops team can develop. Nagios is one of the most widely used open-source tools for exactly this purpose.
This tutorial walks through installing and configuring Nagios Core on a Debian-based Linux server, setting up the Nagios Remote Plugin Executor (NRPE) on a separate host, and verifying each stage of the setup so you end up with a working Nagios server capable of monitoring remote hosts.
What This Tutorial Covers
- All prerequisite software required by Nagios Core on a Debian-based Linux server
- Nagios Core installation and initial configuration on the monitoring server
- Nagios Remote Plugin Executor (NRPE) on both the Nagios server and the remote host being monitored
- Nagios Plugins on both the server and the remote host
- Smoke tests at each stage to confirm successful installation and configuration
By the end, you will have a Nagios server actively monitoring a remote Nagios host via NRPE.
A Brief Overview of Nagios
Nagios was first released in 2002 and quickly became a foundational reference for infrastructure monitoring systems. Originally built for Linux, Nagios now runs on several Unix variants including FreeBSD, Solaris, macOS, and IBM Power platforms.
Nagios Core vs. Nagios XI
Nagios ships in two editions:
- Nagios Core — The open-source, community-supported edition. Well suited to small- and mid-sized businesses, startups, and teams that prefer flexibility and want to avoid licensing costs.
- Nagios XI — The commercial, proprietary edition. Adds features such as dashboards, capacity planning, and detailed reporting. A practical choice for larger organizations with formal auditing or compliance requirements, such as those subject to HIPAA or financial regulations.
What Nagios Can Monitor
Nagios is capable of monitoring a broad range of infrastructure components, including:
- System resources: disk usage, memory consumption, CPU load, swap space
- Network activity: bandwidth, packet loss, latency
- Services and daemons: SSH, Apache/Nginx, SMTP, FTP
- Applications: CRM platforms, databases, and custom application endpoints
- Network devices: routers, switches, firewalls, and disaster recovery appliances
Prerequisites
Before installing Nagios Core on a Debian-based server (Ubuntu LTS is a common choice), ensure the following packages are available:
sudo apt-get update
sudo apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-devCode language: JavaScript (javascript)
These packages provide the build toolchain and web server components that Nagios Core depends on.
Installing Nagios Core
Download the latest stable Nagios Core source tarball from the official Nagios website, then compile and install it:
# Download and extract (replace VERSION with the current release)
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-VERSION.tar.gz
tar xzf nagios-VERSION.tar.gz
cd nagios-VERSION
# Compile and install
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
sudo make install-groups-users
sudo usermod -aG nagios www-data
sudo make install
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconfCode language: PHP (php)
After installation, create the Nagios admin web interface user and enable required Apache modules:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo a2enmod rewrite cgi
sudo systemctl restart apache2
sudo systemctl enable nagios
sudo systemctl start nagios
Verify the installation by opening http://<server-ip>/nagios in a browser and logging in with the credentials you just created.
Installing Nagios Plugins
Nagios Plugins provide the individual checks that Nagios uses to assess host and service health. Install them on both the monitoring server and any remote host you plan to monitor:
# Install dependencies
sudo apt-get install -y libssl-dev
# Download, compile, and install the plugins
wget https://nagios-plugins.org/download/nagios-plugins-VERSION.tar.gz
tar xzf nagios-plugins-VERSION.tar.gz
cd nagios-plugins-VERSION
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make installCode language: PHP (php)
Setting Up NRPE for Remote Host Monitoring
The Nagios Remote Plugin Executor (NRPE) allows the Nagios server to run checks on remote Linux hosts securely. NRPE must be installed and configured on both sides.
On the Remote Host (the machine being monitored)
sudo apt-get install -y nagios-nrpe-server nagios-plugins-basic
# Edit the NRPE configuration to allow connections from the Nagios server
sudo nano /etc/nagios/nrpe.cfg
# Set: allowed_hosts=127.0.0.1,<nagios-server-ip>
sudo systemctl restart nagios-nrpe-server
sudo systemctl enable nagios-nrpe-serverCode language: PHP (php)
On the Nagios Server
sudo apt-get install -y nagios-nrpe-plugin
# Test connectivity to the remote host
/usr/lib/nagios/plugins/check_nrpe -H <remote-host-ip>Code language: PHP (php)
A successful response returns the NRPE version string from the remote host. If the connection fails, check firewall rules — NRPE listens on TCP port 5666 by default.
Configuring a Remote Host in Nagios
Create a host definition file on the Nagios server to register the remote machine:
sudo nano /usr/local/nagios/etc/servers/remotehost.cfg
Add a basic host and service definition:
define host {
use linux-server
host_name remotehost
alias Remote Host
address <remote-host-ip>
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
define service {
use generic-service
host_name remotehost
service_description CPU Load
check_command check_nrpe!check_load
}Code language: HTML, XML (xml)
After saving, verify the configuration and reload Nagios:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl reload nagios
Where to Start: Prioritizing What to Monitor
IT administrators new to Nagios often face decision paralysis when trying to decide which hosts and services to monitor first. A practical approach is to begin with mission-critical components — production web servers, databases, and core network devices — and expand coverage incrementally. Nagios makes it straightforward to add, modify, or remove hosts and service checks without disrupting existing monitoring.
Suggested starting points for most environments:
- Disk usage on all servers (alert at 80%, critical at 90%)
- CPU load on application and database servers
- Memory and swap consumption
- SSH availability on all managed hosts
- HTTP/HTTPS availability and response time for public-facing services
- Database service status (MySQL, PostgreSQL)
- SMTP relay health if you operate internal mail infrastructure
Summary
Nagios Core provides a robust, extensible foundation for proactive infrastructure monitoring at no licensing cost. By following the steps above — installing prerequisites, compiling Nagios Core, deploying Nagios Plugins, configuring NRPE on remote hosts, and defining host and service objects — you will have a monitoring stack capable of alerting your team to problems before users are affected.
For organizations that need built-in dashboards, automated reports, or capacity planning features without managing configuration files manually, Nagios XI is worth evaluating as an upgrade path.