We are going to upgrade Nagios Core from 4.1.1 to 4.3.4.
Backup Existing Nagios Configuration
Nagios and Apache services should be stopped:
# systemctl stop nagios httpd
Make sure that we have a backup:
# rsync -rav /usr/local/nagios/ /opt/nagios411backup/
Upgade and Configuration
Download Nagios Core release 4.3.4 and extract the archive:
# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz # tar xf ./nagios-4.3.4.tar.gz && cd ./nagios-4.3.4
Configure and compile:
# ./configure --with-command-group=nagcmd # make all
Install the main program, CGIs, HTML files, sample config files etc:
# make install # make install-init # make install-commandmode # make install-config # make install-webconf # make install-webconfig
Restore the configuration file nagios.cfg
from the backup:
# cp -f /opt/nagios411backup/etc/nagios.cfg /usr/local/nagios/etc/
Restore the password file htpasswd.users
if required:
# cp -f /opt/nagios411backup/etc/htpasswd.users /usr/local/nagios/etc/
Restore objects:
# rsync -rav /opt/nagios411backup/etc/objects/ /usr/local/nagios/etc/objects/
In our case we also want to restore all custom monitoring configuration files:
# rsync -rav /opt/nagios411backup/etc/monitoring/ /usr/local/nagios/etc/monitoring/
These are deprecated and will be removed in future versions, might as well change them now:
# sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/templates.cfg # sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/printer.cfg # sed -i 's/normal_check_interval/check_interval/g' /usr/local/nagios/etc/objects/switch.cfg
# sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/templates.cfg # sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/printer.cfg # sed -i 's/retry_check_interval/retry_interval/g' /usr/local/nagios/etc/objects/switch.cfg
# sed -i 's/^command_check_interval/#command_check_intervald/g' /usr/local/nagios/etc/nagios.cfg
We use Nagiosgraph, therefore we need this to continue processing data (the config file which we restored from the backup does contain the line already, therefore it’s mainly for future references).
# sed -i 's/process_performance_data=0/process_performance_data=1/g' /usr/local/nagios/etc/nagios.cfg
Reload and restart the services:
# systemctl daemon-reload # systemctl restart nagios # systemctl restart httpd
Verify:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.3.4 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2017-08-24 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 1671 services. Checked 190 hosts. Checked 44 host groups. Checked 47 service groups. Checked 5 contacts. Checked 6 contact groups. Checked 126 commands. Checked 7 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 190 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 7 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
If there are any configuration mismatches between the old and the new Nagios versions that affect your set up, then change them accordingly.
References
https://arkit.co.in/nagios-core-upgrade/