How to Install and Configure Nagios on Ubuntu

Nagios XI Installation

How to Install and Configure Nagios on Ubuntu 16.04

Nagios is an enterprise-class open source software for monitoring network infrastructures, servers, and applications. Nagios can monitor Network services, Host resources, Linux and Windows servers and applications as well as web applications. Today I’m Going to tell you how you can install and configure Nagios On Ubuntu.  Some of the features include parallel service checks, plugin system, notifications via email, pager or user-defined service, a web interface for viewing status, log files, problem history and notifications and much more.



Install the necessary packages To Install and Configure Nagios

Log in to your VPS via SSH as a sudo user:

ssh username@IP_Address

Once you are logged in, run the following commands to update all installed packages:

sudo apt-get update sudo apt-get upgrade

Once the update is completed, install the packages necessary for building Nagios with the following command:

sudo apt-get install autoconf gcc libc6 make wget unzip libgd-dev

Install Apache, MySQL, and  PHP To Install Nagios.

To install Nginx, MySQL, PHP 7 and all required PHP modules on your Ubuntu server run the following command:

sudo apt-get install apache2 php libapache2-mod-php7.0 php-mysql mysql-server

When the MySQL installation is complete, secure your MySQL installation by issuing the following command:

sudo mysql_secure_installation

Enable MySQL and Apache to start on boot with:

sudo systemctl enable apache2.service sudo systemctl enable mysql.service

Download and Install Nagios

To download the latest version of the Nagios archive in the /tmp directory on your server run the following command:

wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.1.tar.gz -O /tmp/nagioscore.tar.gz



Once the download is finished change to the /tmp directory and extract the tarball by issuing the following commands:

cd /tmp sudo tar xf nagioscore.tar.gz

Change to the nagioscore-nagios-4.4.1 directory:

cd /tmp/nagioscore-nagios-4.4.1

Next step is to start the ./configure script that will check your Ubuntu server for missing libraries and binaries and prepare the Nagios source code for the compile process:

./configure

Now that the configuration is completed start the compilation process using the make all command:

make all

Next, issue the following command which will create a user and group names “nagios” and add the www-data user to the nagios group:

sudo make install-groups-users sudo usermod -a -G nagios www-data

You can now install Nagios files using the make install command:

sudo make install

Install the Nagios sample configuration files by running the following command:

sudo make install-config

To manage your Nagios service using the systemctl command install the initialization script:

sudo make install-daemoninit

Next, install and enable the Apache web server configuration files with:

sudo make install-webconf ln -s /etc/apache2/conf.d/nagios.conf /etc/apache2/conf-available/nagios.conf

Restart apache service:

sudo systemctl restart apache2

10 Reasons Why Parrot Security OS Is Better Than Kali Linux.

Use the htpasswd command to create a user account called nagiosadmin

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

Enter the new user password when prompted.

Run the following command to install and configure the external command file:

sudo make install-commandmode

Install Nagios Plugins

Before downloading and compiling Nagios plugins install the following packages:

sudo apt-get install autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext

Next, download the latest stable version of the Nagios archive in the /tmp directory on your server with:

wget –no-check-certificate -O /tmp/nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios- plugins/archive/release-2.2.1.tar.gz

When the download is completed change to the tmp directory extract the archive with the following commands:

cd /tmp sudo tar xf nagios-plugins.tar.gz

Once the Nagios Plugins archive is extracted, switch to the nagios-plugins-release-2.2.1 directory:

cd /tmp/nagios-plugins-release-2.2.1/

The following commands will check your system for missing libraries and binaries and prepare the Nagios Plugins source code for the build process:

Best Themes For Parrot Security OS. (Mate Desktop Themes)

./tools/setup

./configure

Once the configuration is completed start the compilation process using the make command:

make

The last step is to install the Nagios Plugins using the make install command:

sudo make install

Access Nagios

Now that you have both Nagios and Nagios Plugins installed on your Ubuntu system, start the Nagios service with the following command:

systemctl start nagios

Open your browser and navigate to http://your-domain-or-ip/nagios and you will be presented with the login pop-up.

How To Install Kali Linux And Windows 10 With Dual Boot.

Enter the login credentials that you created earlier with the htpasswd command and you will be redirected to the Nagios home page as shown on the image below:

Nagios Core

That’s it. You have successfully installed Nagios on Ubuntu 16.04. For more information about how to manage your Nagios installation, please refer to the official Nagios documentation.



Author Bio: Jeff Wilson is a senior Linux system administrator at LinuxHostSupport, Missouri based premium server management company that focuses on Linux server administration and outsourced web hosting support services.

More For You

One Thought to “How to Install and Configure Nagios on Ubuntu”

  1. abella

    Great article. It was fun working on the project. Thanks to you for sharing the idea. I now know a thing or two more than I did before this. I am looking forward to adding more features to it soon.

Leave a Reply