Overview

Nagios is an incredible open source monitoring tool. It is actually a full featured monitoring solution for your IT infrastructure. Nagios has capability of monitoring Servers, Firewalls, Routers, Switches, Services and Applications. We can access the Nagios using web interface.
With Nogios you can:

`

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

In this Howto I will explain the steps involved in installing and configuring Nagios for monitoring your Centos 7 Server.
With this basic setup you will be able to monitor some important services of your Linux Server (Centos 7).

Installation

This guide is based on Centos 7, so i have already setup Centos 7 machine with minimal installation.

Prerequisites:

Our first requirement is to install Apache and PHP. Use the following yum command to install these packages.

# yum install -y httpd php gcc glibc perl glibc-common gd gd-devel wget
# service httpd start
# chkconfig httpd on

Never forget to open http port in firewall.
Add accept rule in iptables to allow port 80 over the network.

# iptables -I INPUT -p tcp –dport 80 -j ACCEPT

Save newly added firewall rule, as it will be flushed on system restart or firewall service.
use below command to save newly added firewall rule.

# service iptables save

Installing Nagios

Before installing Nagios we need to create one user and add nagcmd group, then add nagios and apache user in nagcmd group.

# useradd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

Downloadig and Compiling Nagios Core.

Change directory to /opt.

# cd /opt

Dowload source.

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

Extract tar file.

# tar -zxvf /opt/nagios-4.0.7.tar.gz
# cd /opt/nagios-4.0.7/

Now I am going to compile and configure it with the recently created user/group and some additional options:

./configure –with-nagios-group=nagios –with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
# make install-webconf

For basic functioning of Nagios Some sample configuration files are created and installed under /usr/local/nagios/etc directory.
We need to update our email address in /usr/local/nagios/etc/objects/contacts.cfg config file for receiving monitoring related notifications and alerts.

# vi /usr/local/nagios/etc/objects/contacts.cfg

Change the Email address with your own.

email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
replace nagios@localhost < with your email address
Like this
email admin@broexperts.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Save & Exit.

Now create one username and password using apache authentication, which will use to access web interface of Nagios.

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

Downloading and Installing Nagios Plugins

Go to /opt directory and download plugin source file.

# cd /opt
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar -zxvf /opt/nagios-plugins-2.0.3.tar.gz
# cd /opt/nagios-plugins-2.0.3/

Use following command to install and compile plugins.

# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make
# make install

Restart Apache service to make the new settings take effect.

# service httpd restart

Now verify and Start Nagios

Use the below commands to verify nagios install.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there is no error return then start Nagios Service

# service nagios start

Also configure nagios service to start on system start

# chkconfig nagios on

Test Web Access

Open up web browser and point this url in address bar
http://192.168.1.200/nagios. [change server name or ip according to your setup].

You will be prompted for the username and password, provide username nagiosadmin and password whatever you kept.

Nagios Monitoring for Linux Server
Nagios Monitoring for Linux Server

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

That’s’ all.

907693_10202910404575103_1812240210_n

Similar Posts