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.
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.
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:
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 nagiosCopy 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.
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 installmake 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:
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.logFix 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:
- Stop Nagioswith
sudo systemctl stop nagios. - Reinstall the previous releasefrom source, using the version you noted, with
make allandsudo make install. - Restore your configurationfrom the backup:
sudo tar xzf /root/nagios-backup-DATE.tar.gz -C /. - Check and start.Run
nagios -v, thensudo systemctl start nagios, and confirm checks and alerts work as before.
4. Configuration file reference
| File | What it controls |
|---|---|
/usr/local/nagios/etc/nagios.cfg | Main settings: log file, cfg_file and cfg_dir lines that load your object files, external commands |
/usr/local/nagios/etc/resource.cfg | Macros such as $USER1$ (the plugin folder) and private values such as passwords |
objects/commands.cfg | Command definitions: how each check or notification is run |
objects/contacts.cfg | Who is alerted, and how |
objects/timeperiods.cfg | When checks and notifications may run |
objects/templates.cfg | Templates such as linux-server and generic-service |
/usr/local/nagios/etc/cgi.cfg | Web interface permissions, for example authorized_for_system_information |
/usr/local/nagios/etc/htpasswd.users | Web 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
| Task | Command |
|---|---|
| Check the configuration | sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
| Reload after a change | sudo systemctl reload nagios |
| Service status | sudo systemctl status nagios |
| Follow the log | sudo tail -f /usr/local/nagios/var/nagios.log |
| Find critical alerts | grep CRITICAL /usr/local/nagios/var/nagios.log |
| Add a web user | sudo 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.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
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.
A self-managed VPS with full root access, ready for Nagios or any monitoring stack you choose.
See VPS plans