Nagios Monitoring

Nagios is one of the oldest and most widely deployed monitoring systems. It uses a check-based model: define hosts and services, define check commands, and Nagios runs those checks on a schedule and alerts when checks fail. Unlike Prometheus (metrics-based), Nagios checks binary state: OK, WARNING, CRITICAL, or UNKNOWN. It is well-suited for traditional infrastructure monitoring where you want to know "is this service up?" rather than "what is the CPU trend over 6 months?"

Nagios architecture

Nagios monitoring model:
  nagios-server runs checks:
    check_http  → GET http://website → 200 OK?
    check_ping  → ICMP to server → responding?
    check_disk  → SSH + NRPE → disk usage?
    check_mysql → connect to DB → running?
       ↓
    OK: no action
    WARNING: notify after N failures
    CRITICAL: notify immediately
    UNKNOWN: check failed to run

Installing Nagios Core

# Install Nagios Core from Ubuntu repos (older but functional):
sudo apt install -y nagios4 nagios-plugins

# Set admin password:
sudo htpasswd -c /etc/nagios4/htpasswd.users nagiosadmin

sudo systemctl enable --now nagios4 apache2
# Access at http://localhost/nagios4

Default Nagios login

URL: http://YOUR_SERVER_IP/nagios4
User: nagiosadmin
Password: (the one you set with htpasswd)

Adding hosts and services

# Create a host configuration:
sudo nano /etc/nagios4/conf.d/webserver01.cfg

/etc/nagios4/conf.d/webserver01.cfg

define host {
    use                 linux-server
    host_name           webserver01
    alias               Web Server 01
    address             192.168.1.50
    max_check_attempts  3
    notification_interval 60
    contact_groups      admins
}

define service {
    use                 generic-service
    host_name           webserver01
    service_description HTTP
    check_command       check_http!-H webserver01
    max_check_attempts  3
}

define service {
    use                 generic-service
    host_name           webserver01
    service_description Disk Usage
    check_command       check_disk!-w 20% -c 10% -p /
}
sudo nagios4 -v /etc/nagios4/nagios.cfg    # Verify config
sudo systemctl reload nagios4

NRPE remote checks

# NRPE (Nagios Remote Plugin Executor) runs checks on remote servers:
# On the monitored server:
sudo apt install -y nagios-nrpe-server nagios-plugins

# Configure /etc/nagios/nrpe.cfg:
# allowed_hosts=192.168.1.100   ← your Nagios server IP
# command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /

sudo systemctl enable --now nagios-nrpe-server

# On the Nagios server, check via NRPE:
/usr/lib/nagios/plugins/check_nrpe -H 192.168.1.50 -c check_disk

Conclusion

Nagios is still widely deployed in traditional enterprise environments where the check-based "up/down" monitoring model fits the operations team's workflow. Its main limitation compared to modern tools is the configuration format (text-based config files, not web UI or YAML) and lack of time-series metrics for trending. For new deployments, Prometheus+Grafana is usually the better choice. For existing Nagios environments, Icinga2 is a compatible replacement that adds better configuration tooling while maintaining plugin compatibility.

FAQ

Is Nagios Monitoring important for Ubuntu administrators?+

Yes. It supports practical Ubuntu administration because it connects directly to server reliability, security, troubleshooting, or daily operations.

Should I practice this on a live server?+

Use a lab VM first. After you understand the command output and rollback path, apply the workflow carefully on real systems.

What should I do after reading this article?+

Run the practice commands, write down what each one shows, and continue to the next article in the Ubuntu roadmap.

Need help with Ubuntu administration?

Work directly with Muhammad Irfan Aslam for Ubuntu Server, Linux, cloud, Docker, DevOps, CI/CD, or infrastructure troubleshooting support.

Hire Me for Support