How to install Nagios Core in Ubuntu

Nagios is an open source powerfull tool to monitor your hosts and services. It easy very easy to configure and use. You can also setup email notifications, SMS notifications and if you can run little bit python scripts you can also setup whatsapp notifcations. However, whatsapp notifcations are not officially by nagios but python script is available for that.

Step 1 : You need to install pre-requirement packages first.

# apt install apache2 libapache2-mod-php php
# apt install wget unzip zip autoconf apache2-utils libgd-dev libc6 make gcc

Step 2: Create nagios user and assign user group to www-data

# useradd nagios
# usermod -a -G nagios www-data

Step 3: Download latest nagios from the official website.

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz

Step 4: Now extract downloaded file into your specific folder. You can extract any where like /tmp or /opt or /usr/local/src. That’s up to you.

# tar xzf nagios-4.4.6.tar.gz
# cd nagios-4.4.6/

Now, You can see some configuration related files the above folder. 3

Step 5: Let’s compile the nagios setup

# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconfig

Step 6: Now enable and restart the nagios server.

# systemctl start nagios
# systemctl enable nagios

Step 7: Setup password ‘nagiosadmin’ user by using below command.

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Step 8: Enable cgi modules to access http server to execute nagios cgi scripts.

# a2enmod cgi
# systemctl restart apache2

Step 9: Thats it. Now just start and enable nagios service and you are good to go.

# systemctl start nagios
# systemctl enable nagios

Now you can able to login your nagios server from web browser via this adress http://ipaddress/nagios or http://FQDN/nagios. Login prompt will appear, you need to login with the user ‘nagiosadmin’ and password you setup in earlier steps.

You also need to install Nagios Plugins to proper monitoring. How to install Nagios Plugins.