Upgrading Ubuntu Nagios 3.5 to 4.x

In this previous post we installed Nagios 3.5.0 from source. Now that the current version of Nagios is 4.0.2 I wanted to walk through upgrading the previous version to the latest.

sudo bash
apt-get update && apt-get ugprade
cd /opt
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.2.tar.gz
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
tar zxvf nagios-4.0.2.tar.gz
tar zxvf nagios-plugins-1.5.tar.gz
cd nagios-4.0.2
./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/bin/sendmail
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If all ran successfully you should see the following.Screen Shot 2013-12-09 at 11.51.47 AM

Now let’s setup the new Nagios plugins.

sudo bash
apt-get install daemon
cd /opt/nagios-plugins-1.5
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install

The new init script installed does not work on Ubuntu so we will remove it and create a new one to run under /etc/init

rm /etc/init.d/nagios
rm /etc/rcS.d/S99nagios

Create /etc/init/nagios.conf **Thanks to raymii.org

# nagios - monitoriong system
# by https://raymii.org

description     "nagios monitoring system"

start on virtual-filesystems
stop on runlevel [06]

respawn limit 5 30
limit nofile 65550 65550

chdir /usr/local/nagios/
setuid nagios
setgid nagios
console log

        exec bin/nagios etc/nagios.cfg
end script

Now you will need to reload the init config to enable nagios

sudo initctl reload-configuration
sudo start nagios

So now if all went well and you connect to http://IP|FQDN/nagios and login you should be presented with the following page.

So there you have it. A few snags in the process but it works.


11 thoughts on “Upgrading Ubuntu Nagios 3.5 to 4.x

  1. I could not understand where you have upgraded it from 3.5 to 4.x. According to subject it should be first install Nagios 3.5 and configure it then show us how to migrate the configuration to 4.x, where what you shown us is how to install 3.5 and 4.x . I beleive, that might be the least required thing "how to install".

    I hope I will get update on this.

      • Appologies for my harsh language if that hurt you. But, still it is not showing how can I migrate from 3.5 to 4.x. it is just showing how can I install 3.5 and now 4.x. What I understand it there is change in format for both the versions and I was expecting a migration process of configuration files from 3.5 to 4.x.

        • @Gourav – Hurt me? HA. No such thing. It's all good. As far as migration and different formats I did not go through that of course. I have not used Nagios since this post so I am not sure about format changes and such. But you have my interest now. Can you send me some specifics that I can look into here soon?

  2. Hi, I have Ubuntu 10.04 LTS in my server in which nagios 3.2.3 is installed. Now I am looking for the way to upgrade it to latest stable release of nagios 4.0.4.

    I followed your blog and downloaded nagios 4.0.4 as well. Now inside nagios-4.0.4 folder, when I tried to compile it with command "make install", it gives error as :

    workers.c:493: error: dereferencing pointer to incomplete type

    workers.c:494: error: ‘WPRES_job_id’ undeclared (first use in this function)

    . Do you have any idea of this ?

  3. Hello, I have installed nagios core 3.x on the same computer install nagios core 4.x.

    What I can not do is to lift all the services configured on the nagios core 3, when entering the nagios core 4.

    Is there any way to read nagios core 4 conf.d directory of nagios core 3?

  4. When you run the following command:

    make install-webconf

    You might see the following error:

    /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
    /usr/bin/install: cannot create regular file /etc/httpd/conf.d/nagios.conf: No such file or directory
    make: *** [install-webconf] Error 1

    Fix the problem by running:

    mkdir -p /etc/httpd/conf.d/nagios.conf

    Finally, run the following command:

    sudo make install-webconf

    • nagios.conf should be moved to /etc/apache2/conf-available.

      cp /etc/httpd/conf.d/nagios.conf /etc/apache2/conf-available/

      From /etc/apache2/conf-available run:

      a2enconf nagios.conf

Leave a Reply

Your email address will not be published. Required fields are marked *