ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install Nagios Core 4.2 on CentOS 7

Nagios is a free and open source monitoring tool that gives a more comprehensive monitoring environment to monitor all your machines and networks. You can monitor your remote hosts and their services remotely on a single window using Nagios. It will give you a warnings and indicates if something goes wrong in your servers which eventually helps you to detect some problems before they occur. It helps you to reduce downtime and business losses. Some of its features are listed below please have a look at them.

  • Monitor your entire IT infrastructure
  • Identify problems before they occur
  • Know immediately when problems arise
  • Share availability data with stakeholders.hypothetical question
  • Detect security breaches
  • Plan and budget for IT upgrades
  • Reduce downtime and business losses.

Requirements

To follow this guide you'll need only a CentOS 7 server and a user with root privileges over it to install Nagios 4.2.0 on your CentOS 7 server. You can switch from non root user to root user using sudo -i command.

Update System

It is highly recommended to install Nagios Core 4.2 on a freshly updated server. Run following command to upgrade available packages and update system.

yum -y update

Install Dependencies

You'll need to install some dependencies required to install Nagios. These dependencies are the Apache web server, PHP and some libraries like gcc, glibc, glibc-common and GD libraries with its development libraries. So first of all let's install Apache web server using following command.

yum -y install httpd

Now you can start Apache and enable it to start at boot time, using the following commands.

systemctl start httpd.service systemctl enable httpd.service

You can check the status of Apache web server using the following command.

systemctl status httpd

Next, install other required dependencies like PHP and some libraries using following command.

yum -y install php gcc glibc glibc-common gd gd-devel make net-snmp

Creating Nagios User and Group

You'll need to create a new nagios user and nagcmd group account and you can do so using following commands.

useradd nagios groupadd nagcmd

Next, add both the nagios user and the apache user to the nagcmd group.

usermod -G nagcmd nagios usermod -G nagcmd apache

Download Nagios Core 4.2

First of all create a new directory and switch to that directory for Nagios Core installtion and all its future downloads. Run following commands and it'll do the job for you.

mkdir /root/nagios cd /root/nagios

If in case you don't have already installed wget package on your server then you can install it using yum -y install wget

Once directory is created now download the Nagios core 4.2 using following command.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz

Next, you'll have to download Nagios plugins 2.1.2 package using following command.

wget https://www.nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

Next, extract these downloaded packages with tar command like shown below:

tar -xvf nagios-4.2.0.tar.gz tar -xvf nagios-plugins-2.1.2.tar.gz

Configure Nagios

Now we will configure Nagios Core and to do so first we'll have to switch to Nagios directory and run following command.

cd nagios-4.2.0 ./configure --with-command-group=nagcmd

Next, you'll need to compile and install all the binaries with make command and make install command will install all the needed libraries in your machine and we can proceed further.

make all make install

Run this command to install the init scripts for Nagios.

make install-init

You'll need to install command-mode so that Nagios can work from command line.

make install-commandmode make install-config

Customize Nagios Configuration

Edit the contacts.cfg file and to do so open this file using any text editor, here we are using nano text editor.

nano /usr/local/nagios/etc/objects/contacts.cfg

Replace email with your own email then save the file and exit from the text editor.

###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
define contact{
contact_name      nagiosadmin ; Short name of user
use               generic-contact ; Inherit default values from generic-contact template (defined above)
alias              Nagios Admin   ; Full name of user
email                      me@sajidbhaijaan.net     ; *** CHANGE THIS TO YOUR EMAIL ADDRESS ****
}

Configure Web Interface

Let's configure the Web Interface For Nagios with following command. The below command will Configure Web interface for Nagios and a web admin user will be created nagiosadmin.

make install-webconf

Now create a password for nagiosadmin and this password will be used when you login in the Nagios Web interface.

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

Restart your Apache web server to apply these changes that we just configured.

systemctl restart httpd.service

Run following commands one by one to compile and install Nagios plugin.

cd /root/nagios cd nagios-plugins-2.1.2/ ./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install

Now we have configured Nagios successfully but it is recommended to verify all the Nagios configuration file. To do so run following command. /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

You should see following output at the end.

Things look okay - No serious problems were detected during the pre-flight check

Finally start Nagios and enable it to start at boot time, using the following commands.

systemctl enable nagios systemctl start nagios.service

Web Access of Nagios

Open up your favorite web browser and please visit http://YourIPaddress/nagios and you'll see a Nagios login page and use nagiosadmin as username and password that you set up earlier to login to Nagios web dashboard.

Conclusion

In this you've learned how to install Nagios Core on your CentOS 7 server and configure it for your server. We hope now you have enough knowledge to work with Nagios Core monitoring tool.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans