How to install Nagios Core 4.4.5 on Ubuntu Server 18.04

User avatar
LHammonds
Site Admin
Site Admin
Posts: 764
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Upgrading Nagios

Post: # 775Post LHammonds
Tue Sep 24, 2019 4:24 pm

Upgrading Nagios

>>> NOT STARTED <<<

Official Documentation

The Plan:
  • Upgrade Nagios Core 4.3.1 to 4.4.5
  • Nagios Plugins 2.2.1 is already current
  • Remote server plugins are already current

User avatar
LHammonds
Site Admin
Site Admin
Posts: 764
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Migrating Nagios

Post: # 776Post LHammonds
Tue Sep 24, 2019 4:25 pm

Migrating Nagios

>>> IN PROGRESS <<<

Once in a while your server's operating system will need to be upgraded to the latest version to enjoy continued security updates, support and features. Although there is an option to "upgrade in place," this is not something I prefer to do. I recommend installing the new operating system on another physical or virtual machine and then get your application up-and-running to prove that it works with the new system. Then copy over the data and logs and ensure the configurations can come over without any issues. Once this entire process is documented, you can then schedule the migration and perform the steps with confidence (especially if you have to wipe out the original server and re-install it fresh).

Old: Ubuntu Server 16.04, Nagios Core 4.4.5 (same paths to configs and logs)
New: Ubuntu Server 18.04, Nagios Core 4.4.5 (same paths to configs and logs)

Build A New Nagios Server

You are basically following this tutorial from start to finish to create a new server with a temporary IP address. One difference is that you will not be concerned with editing the Nagios configuration files.

Before you continue, make sure you have a good full backup of your old and new Nagios servers in case you need to restore something.

Come back to this point once you have a new/blank Nagios server running.

Copy Configuration Files

On the old Nagios server, backup the configuration files:

Code: Select all

sudo tar -czvf /tmp/nagios-cfg.tar.gz /etc/nagios
Copy the archive to the new server:

Code: Select all

scp /tmp/nagios-cfg.tar.gz administrator@192.168.107.18:/tmp/.
On the new Nagios server, make sure the Nagios service is stopped, delete the existing Nagios configuration files and extract the archive.

IMPORTANT NOTE: Make absolutely sure you are typing the below commands on the new/blank Nagios server and NOT your production server by mistake!

Code: Select all

sudo systemctl stop nagios
sudo rm -rf /etc/nagios/*
sudo tar -xzvf /tmp/nagios-cfg.tar.gz -C /
sudo chown --recursive nagios:nagios /etc/nagios/*
sudo chmod --recursive 0664 /etc/nagios/*.cfg
sudo chmod --recursive 0755 /etc/nagios/*.sh
sudo chown root:www-data /etc/nagios/htpasswd.users
sudo chmod 640 /etc/nagios/htpasswd.users
Copy Log Files

On the old Nagios server, backup the log files:

Code: Select all

sudo tar -czvf /tmp/nagios-log.tar.gz /var/nagios/archives/ /var/nagios/status.dat /var/nagios/nagios.log
Copy the archive to the new server:

Code: Select all

scp /tmp/nagios-log.tar.gz administrator@192.168.107.18:/tmp/.
On the new Nagios server, make sure the Nagios service is stopped, delete the existing log files and extract the archive.

Code: Select all

sudo systemctl stop nagios
sudo rm /var/nagios/archive/*
sudo rm /var/nagios/nagios.log
sudo rm /var/nagios/status.dat
sudo tar -xzvf /tmp/nagios-log.tar.gz -C /
sudo chown --recursive nagios:nagios /var/nagios/*
sudo chmod --recursive 0644 /var/nagios/*.log
sudo chmod 0664 /var/nagios/status.dat
Custom Scripts

Look for any scripts on the old server that are not on the new server, then archive them and copy to the new server.

Example of custom scripts I had to migrate:

Code: Select all

/usr/local/nagios/libexec/check_apt_motd.sh
/usr/local/nagios/libexec/check_disk_by_size.sh
/usr/local/nagios/libexec/check_esxi_hardware.py
/usr/local/nagios/libexec/check_snmp_IBM_Bladecenter.pl
On the old Nagios server, backup the custom scripts:

Code: Select all

sudo tar -czvf /tmp/nagios-chk.tar.gz /usr/local/nagios/libexec/check_apt_motd.sh /usr/local/nagios/libexec/check_disk_by_size.sh /usr/local/nagios/libexec/check_esxi_hardware.py /usr/local/nagios/libexec/check_snmp_IBM_Bladecenter.pl
Copy the archive to the new server:

Code: Select all

scp /tmp/nagios-chk.tar.gz administrator@192.168.107.18:/tmp/.
On the new Nagios server, make sure the Nagios service is stopped, extract the archive and set the permissions.

Code: Select all

sudo systemctl stop nagios
sudo tar -xzvf /tmp/nagios-chk.tar.gz -C /
sudo chown nagios:nagios /usr/local/nagios/libexec/*.sh
sudo chown nagios:nagios /usr/local/nagios/libexec/*.pl
sudo chown nagios:nagios /usr/local/nagios/libexec/*.py
sudo chmod 0755 /usr/local/nagios/libexec/*.sh
sudo chmod 0755 /usr/local/nagios/libexec/*.pl
sudo chmod 0755 /usr/local/nagios/libexec/*.py
Swap IP Addresses

Change the IP address of both servers and swap them out so that the new Nagios server is using the old IP and the old Nagios server is using the temporary IP. Reboot both servers at the same time.

When the servers come back up, open a web browser and visit the production IP address and see if all the servers show up along with the prior status and all the historical data in the "availability" and "trends" reports.

Post Reply