How to Install and Configure Nagios On CentOS-6.,RHEL-6.



Hi,


Today My Topic is How to configure Nagios server on Centos-6.. or Rhel-6..This Topic Is very Interested, and I've successfully completed this task...

How to Install and Configure Nagios On CentOS-6.,RHEL-6.

What is Nagios ?

Nagios is an open source computer system monitoring, network monitoring and infrastructure monitoring software application. Nagios offers monitoring and alerting services for servers, switches, applications, and services. It alerts the users when things go wrong and alerts them a second time when the problem has been resolved.More- http://en.wikipedia.org/wiki/Nagios.


Features of Nagios-

1- Monitoring of network services (SMTP, POP3, HTTP, NNTP, etc.).

2- Monitoring of host resources (processor load, disk usage, etc.).

3- Simple plug-in design that allows administrators to develop further service checks.

4- Support for redundant Nagios servers. 


Nagios server Scenario-

OS-       Centos 6.5
IP-        192.168.1.10/24

Nagios Client Scenario-

OS-      Ubuntu 14.04
IP-       192.168.1.9/24


Nagios Server System-


Note-

Before installing Nagios, make sure that you’ve a properly installed and configured LAMP stack in your server.

How To Configure LAMP Server..

https://www.facebook.com/notes/linux-only/how-to-configure-lamp-server-redhat-6-centos-6-/724523114237750

Orhttp://ashutoshlinuxnotes.blogspot.in/p/54.html

Step- 1 

1- Change IP Address.. 

[root@server ashutosh]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

---------------------------------------------------------------

DEVICE="eth0"
IPADDR=192.168.1.10
NETMASK=255.255.255.0
HWADDR="00:16:D4:39:5B:6F"
NM_CONTROLLED="yes"
ONBOOT="yes"

--------------------------------------------------------------

2- Restart Network Service..

[root@server ashutosh]# service network restart

[root@server ashutosh]# ifconfig


Step-2 Install Some following prerequisites packages..

# yum install gd gd-devel gcc glibc glibc-common

Step-3 Now Install Nagios..

Note- Nagios will not be found in CentOS official repositories, so let us add the EPEL repository to install nagios. 

1- How To Install EPEL Repository-

EPEL stands for Extra Packages for Enterprise Linux.

[root@server yum.repos.d]# cd /etc/yum.repos.d/

[root@server yum.repos.d]# wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm

[root@server yum.repos.d]#  rpm -Uvh epel-release-6-8.noarch.rpm

[root@server yum.repos.d]# cd -

[root@server ashutosh]#  

[root@server ashutosh]# yum repolist

2- Then install nagios

[root@server ashutosh]# yum install nagios*

Step- 4 Disable Selinux..or allow the apache port through iptables..

[root@server ashutosh]# vim /etc/sysconfig/iptables

-------------------------------------------------------------------------------

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT



:wq!

--------------------------------------------------------------------------------

[root@server ashutosh]# service iptables restart

Step-5 Now Configure Nagios Server..

1-  Add the admin mail address in the nagios contact file to receive alerts from nagios server.

[root@server ashutosh]# vim /etc/nagios/objects/contacts.cfg 

email                           root@ashu.com ;


:wq! (Save & Quit)


2- Then Edit file /etc/httpd/conf.d/nagios.conf,


Allow The Particular IP Series, Which you want to access nagios administrative console from a particular IP series.

[root@server ashutosh]# vim /etc/httpd/conf.d/nagios.conf

---------------------------------------------------------------------------------

#   Order allow,deny       --> Comment This Line No-15
  Allow from all           --> Comment This Line No-16

# Uncoment and Change Line No. 17,18,19.

Order deny,allowDeny from allAllow from 127.0.0.1 192.168.1.0/24


:wq! (Save & Quit)
---------------------------------------------------------------------------------

3- Set nagios admin password

[root@server ashutosh]# htpasswd /etc/nagios/passwd nagiosadmin

New password:
Re-type new password:
Updating password for user nagiosadmin

4- Now Restart nagios and https service..

[root@server ashutosh]# service nagios start

[root@server ashutosh]#  service httpd start

[root@server ashutosh]# chkconfig nagios on

[root@server ashutosh]# chkconfig httpd on

Step-6 Access Nagios admin Console..

Open Web Browser, And Type..

http://192.168.1.10/nagios/

Image-1

Enter the username as nagiosadmin and its password which we created in the earlier steps.

              
Image-2 Than open Nagios administrative Console..



Click on the “Hosts” section in the left pane of the console.

Note- You will see the no of hosts to be monitored by Nagios server. Initially, the nagios server (localhost) itself will only be monitored.

Click on the monitoring host to display more details..

Image-3
  
Step-7 Add Monitoring targets to Nagios server..

Now let us add some clients to monitor by Nagios server.

Go to Client PC-

Step-1 Change IP Address.. 

[root@server ashutosh]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

---------------------------------------------------------------

DEVICE="eth0"
IPADDR=192.168.1.9
NETMASK=255.255.255.0
HWADDR="00:16:D4:6B:4B:5F"
NM_CONTROLLED="yes"
ONBOOT="yes"

--------------------------------------------------------------

Step-2 Restart Network Service..

[root@server ashutosh]# service network restart

[root@server ashutosh]# ifconfig


Step-3  Install 'nrpe' and nagios-plugins'

If Client System - Centos, RhelThan,

[root@server ashutosh]# yum install nrpe nagios-plugins-all openssl

If Client System Debian,UbuntuThan,

$ sudo apt-get install nagios-nrpe-server nagios-plugins


Step-4 Configure Monitoring Targets..

[root@server ashutosh]# vim /etc/nagios/nrpe.cfg

-------------------------------------------------------------------

# Line No-81# Entry Your Nagios Server IP.

allowed_hosts=127.0.0.1 192.168.1.10

:wq! (Save & Quit)


------------------------------------------------------------------

Step-5 Restart Services..

If Client System - Centos, Rhel

[root@server ashutosh]# service nrpe start[root@server ashutosh]# chkconfig nrpe on

If Client System Debian,Ubuntu

$ sudo /etc/init.d/nagios-nrpe-server restart

Go Back Nagios Server-


Step-8 Add the clients to be monitored through nagios server.

[root@server ashutosh]# vim /etc/nagios/nagios.cfg 

------------------------------------------------------------

cfg_dir=/etc/nagios/servers      -->Uncomment Line No-52


:wq! (Save & Quit)

------------------------------------------------------------

Step-9 Create a directory..

[root@server ashutosh]# mkdir /etc/nagios/servers

Step-10 Create config file to the client to be monitored..

[root@server ashutosh]# vim /etc/nagios/servers/clients.cfg

------------------------------------------------------------

define host{

use                             linux-server

host_name                  client

alias                           client

address                      192.168.1.9  -->Client IP

max_check_attempts      5

check_period                24x7

notification_interval       30

notification_period        24x7

}


:wq! (Save & Quit)

------------------------------------------------------------


Step-11 Restart Nagios Service..

[root@server ashutosh]# service nagios restart

Step-12 Now open the nagios admin console

Open Web Browser and Type- 

http://192.168.1.10/nagios/

Image-4 Click on the “Hosts” sectionNow you will see the newly added client will be visible there.
Click on the host to see if there is anything wrong or alerts.

Click on the monitoring target, you’ll get the detailed output..

Image-5








Note- There, you can define more clients by creating a separate config files “/etc/nagios/servers directory

Step-13 How to Define Particular Services ?

Like if You Want To Define the Monitoring host.Now Add the some services of the monitoring host.For example I want to monitor the ssh service...

[root@server ashutosh]# vim /etc/nagios/servers/clients.cfg 

------------------------------------------------------------

define host{

use                             linux-server

host_name                  client

alias                           client

address                      192.168.1.9    -->Client IP

max_check_attempts         5

check_period                    24x7

notification_interval           30

notification_period             24x7


}


define service {       

use                                generic-service       

host_name                    client       

service_description      SSH       

check_command           check_ssh       

notifications_enabled    0       


}



:wq! (Save & Quit)

------------------------------------------------------------

Step- 14 Restart Nagios Service

# service nagios restart

Now log in to Nagios web console and check for the added services. Navigate to Services section, you’ll see the ssh service there.


http://192.168.1.10/nagios

 


More Info- 

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html



I Hope You Like It,
So Enjoy..


______________________________________________________________________________________

Click Back..                                Click Home..
https://docs.google.com/forms/d/1iNRZlJJO6rBFizzPcFmyOTEtfkdjhdVRmpM74IbiT3o/viewform