How To Install Nagios on Ubuntu 16.04

r00t July 26, 2016

Install Nagios on Ubuntu 16.04

In this tutorial we will show you how to install and configuration of Nagios on your Ubuntu 16.04 server. For those of you who didn’t know, Nagios is an open source software that can be used for network and infrastructure monitoring. Nagios will monitor servers, switches, applications and services. It alerts the System Administrator when something went wrong and also alerts back when the issues has been rectified. Resources that can be monitored include CPU, memory and disk space loads, log files, temperature or hardware errors. It can monitor various parameters and problems for services like HTTP, SMTP, DNS, and with the help of plugins it can be highly extended. Nagios core was originally designed to run under Linux, although it should work under most other unices as well.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Nagios on a Ubuntu 16.04 (Xenial Xerus) server.

Install Nagios on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

Step 2. Install LAMP (Linux, Apache, MariaDB, PHP) server.

A Ubuntu 16.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:

Step 3. Create users and groups for Nagios.

Now create a new nagios user account and setup a password to this account:

Step 4. Installing Nagios and plugins.

First thing to do is to go to Nagios’s download page and download the latest stable version of Nagios, At the moment of writing this article it is version 4.1.1:

Perform below steps to compile the Nagios from the source code:

Next steps, Download latest nagios-plugins source and install using following commands:

Step 5. Configure Nagios.

Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts.

Change the email address field to receive the notification:

Step 6. Configure Apache web server for Nagios.

Now create nagios apache2 configuration file:

Edit the following lines if you want to access nagios administrative console from a particular IP series, Here, I want to allow nagios administrative access from 192.168.1.0/24 series only:

Enable Apache’s rewrite and cgi modules:

Configure Apache authentication:

We need to setup the password for the user nagiosadmin. This username will be used to access the web interface so it is important to remember the password that you will input here. Set the password running the following command and enter the password twice:

Restart Apache for the changes to take effect:

Step 7. Verify and Start Nagios service.

Next we have to make Nagios start at boot time, so first verify that the configuration file has no errors running the following command:

And you should get the output:

Ubuntu 16.04 uses systemd for starting / stopping all the services, so, we need to create nagios.service file:

Add the following lines:

Enable Nagios to start automatically at system startup:

Now, start Nagios service:

Step 8. Accessing Nagios.

Nagios will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com/install.php or http://server-ip/install.php and complete the required the steps to finish the installation. When prompted for username and password you will introduce the username “nagiosadmin” and the password that you entered in step 6.

Install Nagios on Ubuntu 16.04

Congratulation’s! You have successfully installed Nagios. Thanks for using this tutorial for installting Nagios monitoring tool in ubuntu 16.04 (Xenial Xerus) systems. For additional help or useful information, we recommend you to check the official Nagios web site.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!

Save

Share on Google+0Share on Facebook2Tweet about this on TwitterShare on Tumblr0Share on StumbleUpon6Share on Reddit1Pin on Pinterest2
The Tags:

Leave a Comment