Configuring nagios in client

 nagios server=192.168.1.11

 nagios client=192.168.1.13

Installing nrpe and nagios-plugins

 

  • In order to install nrpe and nagios-plugins we have to setup epel repo into our system
  • first check if your system is 32 or 64 bit then get epel rpm into your system and install it
[root@nagios ~]# uname -a

Linux nagios.laure-school 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 #ff0000;">x86_64 GNU/Linux
  • I have 64 bit system so i will be istalling 64 biy epel repo
[root@nagios ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  •  for 32 bit system (i386)  try the command below
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
  •  now install epel rpm you downloaded
[root@nagios ~]# rpm -ivh epel-release-6-8.noarch.rpm

 

  • After yum setup install nrpe
[root@nfsserver ~]# yum install -y nrpe nagios-plugins-all openssl
  •  nagios plugins will be installed at /usr/lib64/nagios/plugins
[root@nfsserver ~]# ls -l /usr/lib64/nagios/plugins
  • now will be modifing nrpe.cfg file inside /etc/nagios directory
  • dont forget backup the nrpe.cfg file before modifying the file
[root@nfsserver ~]#cd /etc/nagios/ [root@nfsserver nagios]# cp nrpe.cfg nrpe.cfg.bak
  • add your nagios server ip in line that says allowed_hosts

 

allowed_hosts=127.0.0.1,192.168.1.13,192.168.1.11
  • if you need to add command or plugin then add ass follows in nrpe.cfg
command[check_users]=/usr/lib64/nagios/plugins/plugin-name -w  -c
  • restart service after modification
[root@nfsserver nagios]# /etc/init.d/nrpe restart
Shutting down nrpe:                                        [  OK  ]
Starting nrpe:                                             [  OK  ]
[root@nfsserver nagios]# chkconfig nrpe on

 

  • Now lets make some configuration in nagios server to add client and services to monitor

 

  • if you have installed nagios from the source and used default settings then
  • your configuration files will be in
[root@nagios etc]# pwd
/usr/local/nagios/etc
  •  we will be creating a directory that will contain clients of our company
  • the file that contains host lists will go under /usr/local/nagios/etc/objects
  • so lets create a folder called velocity-lab
[root@nagios etc]#cd /usr/local/nagios/etc/objects/ 
[root@nagios objects]# mkdir velocity-lab
[root@nagios etc]# cd /usr/local/nagios/etc/objects/
[root@nagios objects]# mkdir velocity-lab
  •  now go to nagios.cfg configuration file and point cfg_dir to the newly created company directory

 

[root@nagios objects]# vi /usr/local/nagios/etc/nagios.cfg  

#cfg_dir=/usr/local/nagios/etc/servers
#cfg_dir=/usr/local/nagios/etc/printers
#cfg_dir=/usr/local/nagios/etc/switches
#cfg_dir=/usr/local/nagios/etc/routers

cfg_dir=/usr/local/nagios/etc/objects/velocity-lab

  •  now we will create two files
  • one for adding clients
  • another for adding services to monitor
  • lets create a file to add clients, nfsserver=our client, 192.168.1.13=ip of our client

if you want to add more you can just add it in this file below } , starting from define and ending at } with clients name and ip.

[root@nagios ~]# vi /usr/local/nagios/etc/objects/velocity-lab/hosts.cfg
define host{
use linux-server
host_name nfsserver
alias nfsserver
address 192.168.1.13
}
  •  now create a file to add services ,  u can add services to monitor according to your needs,
[root@nagios velocity-lab]#cat /usr/local/nagios/etc/objects/velocity-lab/services.cfg
#To check for Ping
define service{
use                     generic-service
host_name               nfsserver
service_description     PING
check_command           check_ping!100.0,20%!500.0,60%
}

# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

define service{
        use                             generic-service
        host_name                       nfsserver
        service_description             Root Partition
        check_command                   check_local_disk!20%!10%!/
        }

# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 users.

define service{
        use                             generic-service
        host_name                       nfsserver
        service_description             Total Processess
        check_command                   check_local_procs!250!400!RSZDT
        }



#Define a service to check the load on the machine.
define service{
use                     generic-service
host_name               nfsserver
service_description     Current Load
check_command           check_nrpe!check_load
}


# Define a service to check SSH on the machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.

define service{
        use                             generic-service
        host_name                       nfsserver
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           0
        }

# Define a service to check HTTP on the machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.

define service{
        use                             generic-service
        host_name                       nfsserver
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }


#Define a service to check the number of currently running procs

define service{
        use                     generic-service
        host_name               nfsserver
        service_description     Total Processes
        check_command           check_nrpe!check_users
}
  • restart services
service nagios restart
service httpd restart

Leave a Reply