Server Management (Unmanaged)

Mastering Nagios: A Comprehensive Guide to Server Monitoring - Part 2

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

This second part covers looking after a running Nagios Core server: upgrading it safely, rolling back if an upgrade goes wrong, and a quick reference to the configuration files and commands you use every day. Nagios runs on a VPS or server you manage, not on shared hosting.

For the full guide

Installation, plugins, host and service definitions and email alerts are in Mastering Nagios: a comprehensive guide to server monitoring. This page follows the same setup: Nagios Core built from source on Ubuntu 24.04, with Ubuntu's monitoring-plugins package in /usr/lib/nagios/plugins.

Key takeaways

Back up /usr/local/nagios/etc before every upgrade. Build the new Nagios Core release from source and run only make all and make install, so your configuration isn't replaced, then check it with nagios -v before restarting. Plugins from the monitoring-plugins package update with the rest of the system. To roll back, reinstall the previous release the same way and restore the backup.

1. Back up before you upgrade

Your configuration and the state files are what matter. Save them with a date in the name:

bash
sudo systemctl stop nagios
sudo tar czf /root/nagios-backup-$(date +%F).tar.gz \
  /usr/local/nagios/etc /usr/local/nagios/var/retention.dat
sudo systemctl start nagios

Copy the archive off the server too. Note the running version from the web interface or with /usr/local/nagios/bin/nagios --version, so you know what to roll back to.

2. Upgrade Nagios Core

Read the release notes first, then build the new release the same way you installed it. Replace VERSION with the release from the project's GitHub releases page.

bash
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
Skip install-config on an upgrade

make install-config writes the sample configuration files and can replace yours. On an upgrade, make install is enough. Run the other install-* targets only if the release notes tell you to.

Then verify and restart:

bash
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl restart nagios
sudo tail -n 50 /usr/local/nagios/var/nagios.log

Fix every error nagios -v reports before you restart. Then open the web interface, confirm the new version number, and check that hosts and services are being checked and alerts still arrive.

Plugins. With Ubuntu's package, plugins update with the system: sudo apt update && sudo apt upgrade. There is nothing to compile.

3. Roll back an upgrade

If the new release misbehaves:

  1. Stop Nagios
    with sudo systemctl stop nagios.
  2. Reinstall the previous release
    from source, using the version you noted, with make all and sudo make install.
  3. Restore your configuration
    from the backup: sudo tar xzf /root/nagios-backup-DATE.tar.gz -C /.
  4. Check and start.
    Run nagios -v, then sudo systemctl start nagios, and confirm checks and alerts work as before.

4. Configuration file reference

FileWhat it controls
/usr/local/nagios/etc/nagios.cfgMain settings: log file, cfg_file and cfg_dir lines that load your object files, external commands
/usr/local/nagios/etc/resource.cfgMacros such as $USER1$ (the plugin folder) and private values such as passwords
objects/commands.cfgCommand definitions: how each check or notification is run
objects/contacts.cfgWho is alerted, and how
objects/timeperiods.cfgWhen checks and notifications may run
objects/templates.cfgTemplates such as linux-server and generic-service
/usr/local/nagios/etc/cgi.cfgWeb interface permissions, for example authorized_for_system_information
/usr/local/nagios/etc/htpasswd.usersWeb interface logins

Keep your own hosts and services in separate files, for example objects/servers.cfg, loaded with a cfg_file line. Then an upgrade or a fresh sample configuration never touches your work. If you monitor remote disks through NRPE, its settings live in nrpe.cfg on each monitored machine, including allowed_hosts, which must list only your Nagios server.

5. Everyday commands

TaskCommand
Check the configurationsudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Reload after a changesudo systemctl reload nagios
Service statussudo systemctl status nagios
Follow the logsudo tail -f /usr/local/nagios/var/nagios.log
Find critical alertsgrep CRITICAL /usr/local/nagios/var/nagios.log
Add a web usersudo htpasswd /usr/local/nagios/etc/htpasswd.users newuser
Run a plugin by hand/usr/lib/nagios/plugins/check_http -H www.example.com -S
Test an NRPE check/usr/lib/nagios/plugins/check_nrpe -H remote-host -c check_disk

Running a plugin by hand, as the nagios user if you can, is the fastest way to see why a check fails. check_nrpe comes from a separate package (nagios-nrpe-plugin on Ubuntu).

6. Keeping it healthy

  • Apply Nagios Core and system updates regularly, and read the release notes each time.
  • Keep the web interface behind HTTPS and a firewall allow list.
  • Store your object files in Git, so every change is recorded and easy to undo.
  • Review alerts every few months: remove checks nobody acts on, and add checks for the problems that caught you out.

7. Where Domain India fits

Nagios needs root access, so it runs on a VPS or server you manage. A Domain India VPS is self-managed with full root access. Websites on Domain India shared hosting can still be monitored from that server with HTTP and certificate checks. 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
Will upgrading Nagios Core overwrite my configuration?

Not if you run only make all and make install. The make install-config step writes the sample configuration and can replace your files, so skip it on an upgrade and back up /usr/local/nagios/etc first.

How do I roll back a Nagios upgrade?

Stop Nagios, reinstall the previous release from source with make all and make install, restore your configuration backup, run nagios -v and start the service again.

How do I update the Nagios plugins?

If you installed Ubuntu's monitoring-plugins package, they update with the system through apt. There is nothing to compile.

Where is the Nagios log file?

With a source install it is /usr/local/nagios/var/nagios.log. Follow it with tail -f while you test changes.

Can I run Nagios on Domain India shared hosting?

No. Nagios needs root access and a background service, which shared hosting doesn't allow. Run it on a VPS and monitor your shared-hosting website from there over HTTP.

Ready to run your own monitoring? Start with part 1 of the Nagios guide, then compare VPS plans.

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 Part 2: Upgrade, Roll Back and Quick Reference