How to Install and Configure Nagios Core From the Source Ubuntu 18.04

0
862

In this tutorial we are going to learn how to build and configure Nagios Core from the source code for server resource consumption and availability monitoring on Ubuntu 18.04.

In our last tutorial, we covered how to Install and Configure Nagios Core from Ubuntu repositories.

Installing Nagios Core From Source on Ubuntu 18.04

Installation from the source ensures that we get latest features, security updates, and bug fixes. Follow through this tutorial to build Nagios and its components from the source.

Install the necessary Nagios build tools and development libraries

# apt-get install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.2 libgd-dev

Download the source code of the latest stable release of Nagios Core from here.

# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.1.tar.gz -P /tmp

Compile and Install Nagios

# cd /tmp
# tar xzf nagios-4.4.1.tar.gz
# cd nagios-4.4.1
# ./configure --with-httpd-conf=/etc/apache2/sites-enabled
# make all

Create a user and a group that will be used to run Nagios. Add apache user to the nagios group

# make install-groups-users
# usermod -aG nagios www-data

Install Nagios Core binaries, CGIs and HTML files.

# make install

Install the init scripts for Nagios services/daemon

# make install-daemoninit

Install and configure permissions on the directory for holding the external command file

# make install-commandmode

Install sample Nagios configuration files in /usr/local/nagios/etc

# make install-config

Install and configure apache web server configuration files and enable apache rewrite and cgi modules

# make install-webconf
# a2enmod rewrite
# a2enmod cgi

If firewall is running, allow apache through it.

# ufw allow Apache;ufw reload

Create a user account for logging into the Nagios web interface.

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

where nagiosadmin is the username for logging in to Nagios Web interface and file htpasswd.users stores user credentials. When adding more users, omit option -c to avoid replacing existing users.

Start and enable both Apache and Nagios services as follows:

# systemctl start apache2;systemctl enable apache2
# systemctl start nagios;systemctl enable nagios

Now access the Nagios web interface using the following URL.

# http://<ip-address>/nagios
eg
# http://192.168.43.156/nagios

You will be prompted to login. So login with admin user created above.

Once you login, this the Nagios dashboard that welcomes you.

By defaultt, Nagios just monitors itself. In our next tutorial, we will learn how to monitor servers using Nagios.

Congratulations you have successfully build and setup Nagios Core from the source code on Ubuntu 18.04. Stay connected for more tutorials on Nagios Configuration and monitoring.

LEAVE A REPLY

Please enter your comment!
Please enter your name here