Server Management (Unmanaged)

Mastering Nagios: A Comprehensive Guide to Server Monitoring

By the Domain India teamPublished 7 min read
Knowledge base article
Contents (9 sections)

Nagios Core is a long-standing open-source monitoring system. It checks your servers, services and websites on a schedule, and alerts you when something fails, before your customers notice. This guide sets up Nagios Core on your own Linux server, adds a first host and service check, and configures email alerts. Nagios needs root access, so it runs on a VPS or server you manage, not on shared hosting.

Key takeaways

Install Nagios Core on a VPS running a current LTS release such as Ubuntu 24.04: build it from the latest source release, add the monitoring plugins from your distribution, and protect the web interface with a password and HTTPS. Define each server as a host and each thing to watch (web, SSH, disk) as a service, run nagios -v to check the configuration, then reload. You can't install Nagios on shared hosting, but a Nagios server elsewhere can still monitor a website hosted there.

1. How Nagios works

Nagios is built from a few simple parts:

Nagios Core
The scheduler. It runs checks, tracks each result and decides when to alert.
Plugins
Small programs such as check_http or check_disk. Each returns OK, WARNING, CRITICAL or UNKNOWN.
Object configuration
Text files that define hosts, services, contacts and time periods.
Web interface
A status dashboard where you view problems, acknowledge them and schedule downtime.

Checks against a remote machine either run from the Nagios server over the network (HTTP, ping, SSH port checks) or run on the remote machine through an agent such as NRPE or over SSH (disk, memory, load).

2. Where to run Nagios

WhereCan you run Nagios there?Notes
Your own VPS or serverYesYou need root to install packages and run the daemon
Domain India shared hostingNoShared accounts can't install system software or run background daemons
Another server watching your shared-hosting siteYesUse HTTP and SSL checks from outside; no agent on the hosting account

Run the monitoring server somewhere other than the servers it watches. If they share a failure, such as the same network, the alert may never be sent.

3. Install Nagios Core on Ubuntu 24.04

These steps follow the Nagios project's own source install. Run them as a user with sudo. Replace VERSION with the current Nagios Core release shown on the project's GitHub releases page.

bash
sudo apt update
sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev openssl libssl-dev

cd /tmp
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-VERSION.tar.gz
tar xzf nagioscore.tar.gz
cd nagioscore-nagios-VERSION

./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
sudo make install-groups-users
sudo usermod -a -G nagios www-data
sudo make install
sudo make install-daemoninit
sudo make install-commandmode
sudo make install-config
sudo make install-webconf

Then enable the Apache modules the interface needs and create the web login:

bash
sudo a2enmod rewrite cgi
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
sudo systemctl restart apache2

Use a long, unique password for nagiosadmin.

4. Add the plugins

The monitoring plugins package from Ubuntu is maintained and updated with the system:

bash
sudo apt install -y monitoring-plugins

It installs the plugins in /usr/lib/nagios/plugins. Point Nagios at that folder by editing /usr/local/nagios/etc/resource.cfg:

text
$USER1$=/usr/lib/nagios/plugins

Then start Nagios and open the interface at http://your-server-ip/nagios:

bash
sudo systemctl enable --now nagios
Don't leave the dashboard open to the internet

The web interface shows your whole infrastructure and can run commands. Serve it over HTTPS with a certificate, restrict it to your own IP addresses in the firewall or the Apache configuration, and keep the Nagios server updated.

5. Define a host and services

Create a file for your servers, for example /usr/local/nagios/etc/objects/servers.cfg, and add it to nagios.cfg with a line cfg_file=/usr/local/nagios/etc/objects/servers.cfg.

text
define host {
    use                 linux-server
    host_name           web01
    alias               Main web server
    address             203.0.113.10
}

define service {
    use                 generic-service
    host_name           web01
    service_description HTTPS
    check_command       check_http!-S -H www.example.com
}

define service {
    use                 generic-service
    host_name           web01
    service_description SSL certificate expiry
    check_command       check_http!-S -H www.example.com -C 21
}

define service {
    use                 generic-service
    host_name           web01
    service_description SSH
    check_command       check_ssh
}

The -C 21 option warns when the certificate has fewer than 21 days left. The linux-server and generic-service templates come with the sample configuration and set sensible check intervals.

To check disk, memory or load on the remote machine, install an agent there, such as NRPE, and use check_nrpe, or use check_by_ssh with an SSH key.

6. Check the configuration and reload

Always verify before reloading. A single typo stops Nagios from starting.

bash
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl reload nagios

The first command lists any errors with the file and line. Fix them all before you reload.

7. Alerts by email

Edit the nagiosadmin contact in objects/contacts.cfg and set your address:

text
define contact {
    contact_name    nagiosadmin
    use             generic-contact
    alias           Nagios Admin
    email           [email protected]
}

Nagios hands alerts to the server's local mail command, so the server must be able to send mail. Direct mail from a new VPS is often rejected or marked as spam. Relay it through an authenticated SMTP service or a mailbox you own, and set SPF for the sending domain. Test by stopping a monitored service briefly and checking that the alert arrives.

  1. Tune intervals.
    A 5-minute check with 3 retries avoids alerts for brief blips.
  2. Use host groups.
    Group servers by role, so you can apply services once to many hosts.
  3. Set downtime
    in the web interface before planned maintenance, so it doesn't page anyone.
  4. Acknowledge problems
    you are working on, so others know.

8. Nagios or something newer?

Nagios is stable, simple to reason about and good for up/down checks. If you mainly want graphs of metrics over time, logs and dashboards, a Prometheus and Grafana stack may suit you better; see production observability with Prometheus, Grafana and Loki. For a wider comparison, see Linux server monitoring tools compared.

9. Where Domain India fits

A Domain India VPS is self-managed, with full root access, so you can install Nagios and point it at any server or website you run. Prices on the card are live and exclude 18% GST.

VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details

Monitoring from outside also works for websites on Domain India shared hosting: HTTP and certificate checks need nothing installed on the hosting account.

Can I install Nagios on Domain India shared hosting?

No. Nagios needs root access and a background daemon, which shared hosting accounts don't allow. Install it on a VPS or server you manage, and monitor your shared-hosting website from there over HTTP.

What operating system should I use for Nagios in 2026?

A current long-term-support release, such as Ubuntu 24.04 LTS or AlmaLinux 9. Avoid end-of-life systems such as CentOS 7.

Where do I get the Nagios plugins?

On Ubuntu, install the monitoring-plugins package, which puts the plugins in /usr/lib/nagios/plugins. Set USER1 in resource.cfg to that folder.

How do I check my Nagios configuration for errors?

Run nagios -v with the path to nagios.cfg. It reports any errors with the file and line. Fix them before reloading the service.

Why are Nagios email alerts not arriving?

The server's local mail is probably being rejected as spam. Relay Nagios mail through an authenticated SMTP service or a mailbox you own, and set SPF for the sending domain.

Can Nagios warn me before an SSL certificate expires?

Yes. Use check_http with the -C option and a number of days, for example -C 21, to get a warning when fewer than 21 days remain.

Ready to start monitoring? Compare VPS plans, then read the VPS firewall setup guide before you open the dashboard to the network.

Run your own monitoring server

A self-managed VPS with full root access, ready for Nagios or any monitoring stack you choose.

See VPS plans

Ready when you are

Get VPS from ₹552.65/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Nagios Core Setup Guide for Your VPS (Ubuntu 24.04)