Nagios Configuration on LINUX/CENTOS

Nagios is an efficient network monitoring tool. This allows you to monitor company network, routers, switches, servers and other applications etc. There are many plugins that are available and its immense community makes Nagios the largest open source monitoring tool. This configuration guides you to install Nagios 4.0.0 on CentOS 6.4.

Step 1: Operating System
Step 2: Configuration of packages
Step 3: Create User and Password
Step 4: Download Nagios Files
Step 5: Edit your email and admin name
Step 6: Configure web Interface
Step 7: Extract and install Plugins
Step 8: Change SELinux setting
Step 9: Configure Host for a local machine
Step 10: Remote Host (Linux Machine) Configuration
Step 11: Install Nagios-plugin
Step 12: Configuration of Remote Host (SERVER)
Step 13: Creation of Host service definition for Local Host
Step 14: To activate check_nrpe
Step 15: login to web-browser

To configure Nagios 4.0.0 tool on centos 6.4 follow the step by step procedure given below:

Step 1: Operating System

Installation of Centos 6.4 ISO (Enterprise-class Linux Distribution) Operating system has done on virtual machine workstation.

Step 2: Configuration of packages

First of all everyone needs to install fedora packages, if not installed and by using the below command download the packages:

#wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

If you get an error then install wget

 #yum install wget

Configuration of some tools that are required: httpd, gcc, glib, glibc-common, gd and gd-devel

#yum install httpd php

#yum install gcc

#yum install glibc glibc-common

#yum install gd gd-devel

Step 3: Create User and Password

Create  nagios  user and password

#/usr/sbin/useradd -m nagios

#passwd nagios

Add  nagcmd  group

/usr/sbin/groupadd nagcmd

/usr/sbin/usermod -a -G nagcmd nagios

/usr/sbin/usermod -a -G nagcmd apache

Step 4: Download Nagios Files

#mkdir downloads  

#cd ~/downloads/

Using the following command you can download nagios-4.0.0

#wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.0/nagios-4.0.0.tar.gz/download?use_mirror=kaz

To unzip the above files use

#tar  -zxvf  nagios-4.0.0.tar.gz

#cd  nagios-4.0.0

#./configure –with-command-group=nagcmd

#make all

#make install

# make install-init

# make install-config

# make install-commandmode

Step 5: Edit your email and admin name

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

Edit contact name, email and alias as per your detail.

Step 6: Configure web Interface

To login on to the web interface you need to create admin account which will be used after configuration of Nagios.

#make install-webconf  

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

Enter   the password.

Restart Apache to accept the setting you have give

#service  httpd   restart

Open web page as: localhost/nagios

Enter: user name :________
Password:_________

Step 7: Extract and install Plugins

To install nagios plugins enter the below command:

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

#cd ~/downloads

#tar -zxvf nagios-plugins-1.4.16.tar.gz

#cd nagios-plugins-.4.16                                             

#./configure -with-nagios-plugins-1.4.16-nagiosadmin=nagios -with-nagios-plugins-.4.16-G=nagios       

#make

#make install                           

Now you have to add nagios to Chkconfig

#chkconfig  –add nagios

#chkconfig nagios on

 1 .  To Verify there are no errors in the configure:

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

Check if there are no errors displayed then start nagios with command:

#service  nagios  start

Step 8: Change SELinux setting

#getenforce

Put SELinux into Permissive mode.

#setenforce 0

OR

Use the following command to run SELinux:

#chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/

#chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

To simplify the   procesure please disable the selinux and  iptables now open your  browser   and http://localhost/nagios

Step 9: Configure Host for a local machine

Edit

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

define host{
use linux-server
host_name localhost
alias localhost
address 127.0.0.1
parents radius
check_command check-host-alive
notification_period 24×7
}
# Define a service to “ping” the local machine
define service{
use local-service
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
use local-service ; Name of service template to use
host_name localhost
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}

Step 10 :  Remote Host (Linux Machine) Configuration

To install nagios NRPE and Nagios-devel:

#wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download?use_mirror=hivelocity&r=&use_mirror=hivelocity

#chkconfig nrpe on

#vi /etc/services

Modify the /etc/services and add the following at the end of the file.

nrpe 5666/tcp # NRPE

Start the service

#netstat –at |grep nrpe

Tcp      0          0          server. Internet.local:nrpe *.*              LISTEN

Create Nagios account

#useradd nagios

#passwd nagios

Step 11 : Install Nagios-plugin

#cd /home/downloads

#tar xvfz nagios-plugins-1.4.16.tar.gz

#cd nagios-plugins-1.4.16

#export LDFLAGS=-ldl

#. /configure -with-nagios-plugins-1.4.16-nagiosadmin=nagios -with-nagios-plugins-1.4.16-  G=nagios -enable-redhat-pthread-work-around

#make

#make install

# chown nagios.nagios /usr/local/nagios # chown -R nagios.nagios /usr/local/nagios/libexec/

1 . Install NRPE

#cd /home/downloads

#tar xvfz nrpe-2.15.tar.gz

#cd nrpe-2.15

#./configure

#make all (Here, if there is any error i.e. make: *** No rule to make target `all’. then Stop     by disable ssl)

#./configure –disable-ssl

# make install-plugin

#make install-daemon

#make install-daemon-config

#make install-xinetd

#service xinetd restart

Verify to make sure the NRPE is functioning properly

# /usr/local/nagios/libexec/check_nrpe -H localhost

NRPE v2.15

1 . Modify the /usr/local/nagios/etc/nrpe.cfg

By default the Remote host comes with nrpe.cfg for few standard check commands i.e. samples. check_users and check_load are :

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

Step 12: Configuration of Remote Host (SERVER)

Download NRPE Add-on
Download nrpe-2.12.tar.gz from Nagios.org and move to /home/downloads

I.  Install check_nrpe on the nagios monitoring server

# tar xvfz nrpe-2.12.tar.gz

# cd nrpe-2.1.2

# ./configure

# make all

# make install-plugin

#./configure       (configuration summary as shown below)

*** Configuration summary for nrpe 2.12 05-31-2008 ***:

General Options:

NRPE port: 5666

NRPE user: nagios

NRPE group: nagios

Nagios user: nagios

Nagios group: nagios

Note: I got the “checking for SSL headers… configure: error: Cannot find ssl headers” error message while performing. /configure. Install openssl-devel as shown below and run the. /configure again to fix the problem.

#yum install openssl-devel

#yum  install krb5-devel

#yum install zlib-devel

#yum install e2fsprogs-devel

Preparing… ########################################### [100%]
1: 2:krb5-devel ######################################### [ 50%]
2:zlib-devel ########################################## [ 70%]
3:openssl-devel ########################################### [90%]4: e2fsprogs-devel ########################################### [ 25%]

Verify whether nagios monitoring server can talk to the remotehost.

#/usr/local/nagios/libexec/check_nrpe -H 192.168.1.129

NRPE v2.12

Step 13: Creation of Host service definition for Local Host

Create a new configuration file

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

To define the host and service definition for this particular remote host

host definition sample:
define host{
use linux-server
host_name solutionsatexperts
alias experts
address 192.168.1.7
contact_groups admins
check_command check-host-alive
retry_interval 1
max_check_attempts 5
check_period 24×7
notification_interval 30
notification_options d,u,r
}Service definition sample:# DEFINE SERVICES:
# Define a service to “ping” the local machine
define service{
use local-service
host_name solutionsatexperts
service_description PING
check_period 24×7
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service
host_name solutionsatexperts
service_description Root Partition
check_period 24×7
notification_options w,c,r
contact_groups admins
}
define service{
use local-service
host_name solutionsatexperts
service_description VMWARE Partition
check_command check_nrpe!check_hda2
check_period 24×7
notification_options w,c,r
contact_groups admins
}
define service{
use local-service
host_name solutionsatexperts
service_description Current Users
check_period 24×7
check_command check_local_users!20!50
}
define service{
use local-service
host_name solutionsatexperts
service_description Total Processe
check_period 24×7
check_command check_local_procs!250!400!RSZDT
}
define service{
use local-service
host_name solutionsatexperts
service_description Current Load
check_period 24×7
check_command check_local_load!5.0,4.0,2.0!10.0,6.0
}
define service{
use local-service
host_name solutionsatexperts
service_description Swap Usage
check_period 24×7
check_command check_local_swap!20!10
}
define service{
use local-service
host_name solutionsatexperts
service_description SSH
check_period 24×7
check_command check_ssh!-p 6381
notifications_enabled 0
}
define service{
use local-service
host_name solutionsatexperts
service_description HTTP
check_period 24×7
check_command check_http
notifications_enabled 0
}
define service{
use local-service
host_name solutionsatexperts
service_description FTP
check_period 24×7
check_command check_ftp!21
}
define service {
use generic-service
host_name solutionsatexperts
service_description DNS Service
check_command check_dns! ns1. solutions. in
}

Step 14 : To activate check_nrpe command define a command in commands.cfg file

Edit

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

and
add the following:

# ‘check_dns’ command definitiondefine command {
command_name check_dns
command_line $USER1$/check_dns -H $ARG1$ -s $HOSTADDRESS$
}
# ‘check_openvpn’ command definition
define command {
command_name check_openvpn
command_line /usr/local/nagios/libexec/check_openvpn -t $ARG1$ -p $ARG2$ -n
$ARG3$
}
# ‘check_nrpe’ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Note: In all the above examples, replace localhost with the corresponding hostname of your localhost.

Restart the nagios service
Restart the nagios as shown below and login to the nagios web (http://nagios-server/nagios/) to verify the status of the localhost linux sever that was added to nagios for monitoring.

#service nagios reload

HOST GROUP DEFINITION:
# Define an optional hostgroup for Linux machines

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

# Define an optional hostgroup for Linux machinesdefine hostgroup{
hostgroup_name   linux-servers ; The name of the hostgroup
alias           Linux Servers ; Long name of the group
}
members solutions; Comma separated list of hosts that belong to this group
}
define host{
use linux-server            ; Name of host template to use
; This host definition will inherit all variables that are defined  ; in (or inherited by) the linux-server host template definition.
host_name                  localhost
alias                            localhost
address      127.0.0.1 192.168.1.7
}

#service nagios reload

Step 16 : Login to web  browser

#localhost/nagios

 

 

 

 

For More detail you can watch video and also subscribe for more Videos :

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk