Home » » Nagios NRPE add Services to Monitor ( cho serve linux)

Nagios NRPE add Services to Monitor ( cho serve linux)

Written By Giai phap ma nguon mo on Thursday, July 21, 2011 | 4:27 AM

NRPE Remote Server Installation and Setup

Create Nagios user account on remote server to be monitored:

# useradd nagios
# passwd nagios

Download and Install Nagios Plugins:

# mkdir -p /opt/Nagios/Nagios_Plugins
# cd /opt/Nagios/Nagios_Plugins
Save file to directory /opt/Nagios
As of this writing Nagios 3.0.6 (Stable) and Nagios Plugins 1.4.13 (Stable)
Extract Files:
# tar xzf nagios-plugins-1.4.13.tar.gz

# cd nagios-plugins-1.4.13

Compile and Configure Nagios Plugins

** You need the openssl-devel package installed to compile plugins with ssl support. **
# yum -y install openssl-devel
Instal Plugins:
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install
The permissions on the plugin directory and the plugins will need to be changed to nagios user
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
Package xinted is needed
# yum install xinetd

Downlad and Install NRPE Daemon

# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
Save file to directory /opt/Nagios
As of this writing NRPE 2.12 (Stable)
Extract the Files:
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12

Compile and Configure NRPE

** You need the openssl-devel package installed to compile NRPE with ssl support. **
# yum -y install openssl-devel
Install NRPE:
# ./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

Post NRPE Configuration

Edit Xinetd NRPE entry:
Add Nagios Monitoring server to the “only_from” directive
# vi /etc/xinetd.d/nrpe

only_from = 127.0.0.1 <nagios_ip_address>
Edit services file entry:
Add entry for nrpe daemon
# vi /etc/services

nrpe      5666/tcp    # NRPE
Restart Xinetd and Set to start at boot:
# chkconfig xinetd on

# service xinetd restart

Test NRPE Daemon Install

Check NRPE daemon is running and listening on port 5666:
# netstat -at |grep nrpe
Output should be:
tcp    0    0 *:nrpe    *.*    LISTEN
Check NRPE daemon is functioning:
# /usr/local/nagios/libexec/check_nrpe -H localhost
Output should be NRPE version:
NRPE v2.12

Open Port 5666 on Firewall

Make sure to open port 5666 on the firewall of the remote server so that the Nagios monitoring server can access the NRPE daemon.

Nagios Monitoring Host Server Setup

Downlad and Install NRPE Plugin

# mkdir -p /opt/Nagios/Nagios_NRPE
# cd /opt/Nagios/Nagios_NRPE
Save file to directory /opt/Nagios
As of this writing NRPE 2.12 (Stable)
Extract the Files:
# tar -xzf nrpe-2.12.tar.gz
# cd nrpe-2.12

Compile and Configure NRPE

# ./configure 

# make all

# make install-plugin

Test Connection to NRPE daemon on Remote Server

Lets now make sure that the NRPE on our Nagios server can talk to the NRPE daemon on the remote server we want to monitor. Replace “<IP of Remote Server>” with the remote servers IP address.
# /usr/local/nagios/libexec/check_nrpe -H <IP of Remote Server>
NRPE v2.12

Create NRPE Command Definition

A command definition needs to be created in order for the check_nrpe plugin to be used by nagios.
# vi /usr/local/nagios/etc/objects/commands.cfg
Add the following:
###############################################################################
# NRPE CHECK COMMAND
#
# Command to use NRPE to check remote host systems
###############################################################################

define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }

Create Linux Object template

In order to be able to add the remote linux machine to Nagios we need to create an object template file adn add some object definitions.
Create new linux-box-remote object template file:
# vi /usr/local/nagios/etc/objects/linux-box-remote.cfg
Add the following and replace the values “host_name” “alias” “address” with the values that match your setup:
** The “host_name” you set for the “define_host” section must match the “host_name” in the “define_service” section **
define host{
          name                  linux-box-remote             ; Name of this template
          use                   generic-host          ; Inherit default values
          check_period          24x7
          check_interval        5
          retry_interval        1
          max_check_attempts    10
          check_command         check-host-alive
          notification_period   24x7
          notification_interval 30
          notification_options  d,r
          contact_groups        admins
          register              0          ; DONT REGISTER THIS - ITS A TEMPLATE
          }

define host{
          use       linux-box-remote     ; Inherit default values from a template
          host_name Centos5    ; The name we're giving to this server
          alias     Centos5 ; A longer name for the server
          address   192.168.0.5   ; IP address of the server
          }

define service{
          use                 generic-service
          host_name           Centos5
          service_description CPU Load
          check_command       check_nrpe!check_load
          }
define service{
          use                 generic-service
          host_name           Centos5
          service_description Current Users
          check_command       check_nrpe!check_users
          }
define service{
          use                 generic-service
          host_name           Centos5
          service_description /dev/hda1 Free Space
          check_command       check_nrpe!check_hda1
          }
define service{
          use                 generic-service
          host_name           Centos5
          service_description Total Processes
          check_command       check_nrpe!check_total_procs
          }
define service{
          use                 generic-service
          host_name           Centos5
          service_description Zombie Processes
          check_command       check_nrpe!check_zombie_procs
          }
Activate the linux-box-remote.cfg template:
# vi /usr/local/nagios/etc/nagios.cfg
And add:
# Definitions for monitoring remote Linux machine
cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg
Verify Nagios Configuration Files:
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors:   0
Restart Nagios:
# service nagios restart
Check Nagios Monitoring server that the remote linux box was added and is being monitored !

TroubleShooting

NRPE ./configure error:

checking for SSL headers… configure: error: Cannot find ssl headers

Solution:
You need to install the openssl-devel package
# yum -y install openssl-devel

CHECK_NRPE: Error – Could not complete SSL handshake

Solution:
This is most likely not a probem with SSL but rather with Xinetd access restrictions.
Check the following files:
/etc/xinetd.d/nrpe
/etc/hosts.allow
/etc/hosts.deny

no acceptable c compiler found in $PATH

When I gave the ./configure command i got this error saying: no acceptable c compiler found in $PATH and then it stops.
After a quick google search I found a topic saying that i needed to install gcc so i entered:
yum install gcc glibc glibc-common gd gd-devel
(thanks to AgentOOX)
Share this article :

0 comments:

Post a Comment