Nagios uzak makine ekleme NRPE

OMÜ wiki sitesinden

Nagios kullanarak, uzaktaki bir sunucuyu monitor edebilmek için yapılması gerekenler aşağıda açıklanmıştır.

İstemci tarafı kurulumu

Not: İstemci tarafı kurulumu için openssl-devel paketine ihtiyaç duyulmaktadır kurmak için,

yum -y install openssl-devel

1. Uzak istemci için nagios kullanıcısı açılır.

useradd nagios
passwd nagios

2. Nagios plugins indirilir ve kurulur.

mkdir -p /opt/Nagios/Nagios_Plugins
cd /opt/Nagios/Nagios_Plugins
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
tar xzf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16

Konfugurasyon ve kurulum için,

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

Klasör izinleri aşağıdaki gibi değiştirilerek kuruluma devam edilir.

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

3. Xinetd paketi kurulur.

yum install xinetd

Plugin kurulumundan sonra sıra, NRPE kurulumuna geldi.

4. NRPE kurulumu için klasör hazırlanır.

mkdir -p /opt/Nagios/Nagios_NRPE
cd /opt/Nagios/Nagios_NRPE

5. NRPE indirilir (http://www.nagios.org/download/addons/)

6. İndirilen dosyalar extract edilir ve klasörüne girilir.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar xzf nrpe-2.13.tar.gz
cd nrpe-2.13

7. NRPE kurulumu başlatılır.

./configure 
General Options:
-------------------------
NRPE port:    5666
NRPE user:    nagios
NRPE group:   nagios
Nagios user:  nagios
Nagios group: nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd

8. Bu aşamada kurulum bitmiştir aşağıdaki ayarların yapılması gerekmektedir.( only_from yazan kısma, monitör eden sunucu ipsini ekleyin)

vi /etc/xinetd.d/nrpe
only_from = 127.0.0.1 192.168.55.55 #nagiosserver' ip address

9. Services e NRPE servisini eklemek gerekmektedir.

vi /etc/services

nrpe         5666/tcp                           # NRPE

10. Xinetd'yi başlatın ve sistem yeniden başladığında başlayacak şekilde ayarlayın.

chkconfig xinetd on
service xinetd restart

Test İşlemleri
Aşağıdaki iki komutla çalışıp çalışmadığını test edebilirsiniz.

netstat -at |grep nrpe

çıktısı,

tcp    0    0 *:nrpe    *.*    LISTEN

Diğer bir komut ise,

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

çıktısı aşağıdaki gibi ise, kurulum başarılı bir şekilde sonuçlanmış demektir.

NRPE v2.12

Not: Uzak sunucuda ayrıca 5666 nolu portun firewalldan açılması gerekmektedir.



Monitöring Host yani Sunucu tarafı kurulumu

yum -y install openssl-devel
mkdir -p /opt/Nagios/Nagios_NRPE
cd /opt/Nagios/Nagios_NRPE
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz
tar xzf nrpe-2.13.tar.gz
cd nrpe-2.13
./configure 
make all
make install-plugin

Kurulum tamamlanır ve test için,

/usr/local/nagios/libexec/check_nrpe -H <IP of Remote Server>
NRPE v2.13

Uzaktaki sunucuyu eklemek için etc/nagios/objects/ klasörüne remotehosts.cfg isimli şu dosya eklenir ve nagios servisi yeniden başlatılır.

vi etc/nagios/objects/remotehosts.cfg
###############################################################################
# REMOTEHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 05-31-2007
#
# NOTE: This config file is intended to serve as an *extremely* simple
#       example of how you can create configuration entries to monitor
#       the local (Linux) machine.
#
###############################################################################




###############################################################################
###############################################################################
#
# HOST DEFINITION
#
###############################################################################
###############################################################################

# Define a host for the local machine

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              kaliteizleme.omu.edu.tr
       alias                  kaliteizleme.omu.edu.tr
       address                193.140.29.10
       contact_groups         admins
       }


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              maliteizleme.omu.edu.tr
       alias                  maliteizleme.omu.edu.tr
       address                193.140.29.10
       contact_groups         admins
       }

###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################

# Define an optional hostgroup for Linux machines

#define hostgroup{
#       hostgroup_name  linux-servers ; The name of the hostgroup
 #      alias           Linux Servers ; Long name of the group
  #     members         localhost     ; Comma separated list of hosts that belong to this group
   #    }



###############################################################################
###############################################################################
#
# SERVICE DEFINITIONS
#
###############################################################################
###############################################################################


# Define a service to "ping" the remote machine 

define service{
       use                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       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                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             Root Partition
       check_command                   check_local_disk!20%!10%!/
       }



# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

define service{
       use                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             Current Users
       check_command                   check_local_users!20!50
       }


# 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                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             Total Processes
       check_command                   check_local_procs!250!400!RSZDT
       }



# Define a service to check the load on the local machine.

define service{
       use                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             Current Load
       check_command                   check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
       }



# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free

define service{
       use                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             Swap Usage
       check_command                   check_local_swap!20!10
       }



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

define service{
       use                             local-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             SSH
       check_command                   check_ssh
       notifications_enabled           0
       }



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

define service{
       use                            generic-service         ; Name of service template to use
       host_name                       kaliteizleme.omu.edu.tr
       service_description             HTTP
       normal_check_interval 2
       retry_check_interval 1
       flap_detection_enabled 0
       max_check_attempts 2
       check_command                   check_http
       notifications_enabled           0
       }
define service{
       use                            generic-service         ; Name of service template to use
       host_name                       maliteizleme.omu.edu.tr
       service_description             HTTP
       normal_check_interval 2
       retry_check_interval 1
       flap_detection_enabled 0
       max_check_attempts 2
       check_command                   check_httpv
       notifications_enabled           0
       }

Bu dosya eklendikten sonra, nagios.cfg dosyasına aşağıdaki satır eklenir.

vi /etc/nagios/objects/nagios.cfg 


# Definitions for monitoring remote Linux hosts
cfg_file=/etc/nagios/objects/remotehosts.cfg