Tuesday, March 9, 2010

In pursuit of a monitoring solution for CentOS Linux: Part IV - Nagios Client Installation

Continuation of "In pursuit of a monitoring solution for CentOS Linux"
Part I
Part II
Part III
Part IV - Nagios Client Installation

This is accomplished using Nagios Plugins and the NRPE Daemon to report information to the Monitoring Server.

0. Login as root on Client (Server to be monitored)

1. Install prerequisite packages - openssl-devel and xinetd is needed.
yum install openssl-devel xinetd

2. Create nagios account
useradd nagios
passwd nagios


3. Create folder to store downloaded files
mkdir -p /opt/Nagios/Nagios_Plugins && cd /opt/Nagios/Nagios_Plugins
**Go to http://www.nagios.org/download/download.php and get the URL for the latest versions of the software. Use wget to download to directory.

4. Extract Files
tar xzf nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13


5. Compile and Configure plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


6. Change permissions on plugins and plugin directory
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec


Install NRPE Daemon

7. Create folder to store downloaded files
mkdir -p /opt/Nagios/Nagios_NRPE && cd /opt/Nagios/Nagios_NRPE
**Go to http://www.nagios.org/download/download.php and get the URL for the latest versions of the software. Use wget to download to directory.

8. Extract the files
tar -xzf nrpe-2.12.tar.gz
cd nrpe-2.12


9. Compile and Configure NRPE

./configure

Exected Output
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


10. NRPE Configutation
nano /etc/xinetd.d/nrpe
edit line:
only_from = your.nagios.SERVER.address

nano /etc/services

add line:
nrpe 5666/tcp # NRPE

11. Restart Xinetd and Set to start at boot
chkconfig xinetd on
service xinetd restart


12. Open Port 5666 on Firewall
system-config-securitylevel-tui

13. Test NRPE Daemon

netstat -at |grep nrpe
Expected Output:
tcp 0 0 *:nrpe *.* LISTEN

/usr/local/nagios/libexec/check_nrpe -H localhost
Expected Output:
NRPE v2.12


At this point further configuration is needed on the Nagios Server, to accept data from the client.

14. Login as root on Nagios Server

15. Downlad and Install NRPE Plugin

mkdir -p /opt/Nagios/Nagios_NRPE && cd /opt/Nagios/Nagios_NRPE
**Go to http://www.nagios.org/download/download.php and get the URL for the latest versions of the software. Use wget to download to directory.

16. Extract the Files
tar -xzf nrpe-2.12.tar.gz
cd nrpe-2.12


17. Compile and Configure NRPE
./configure
make all
make install-plugin


18. Test connection to client
/usr/local/nagios/libexec/check_nrpe -H client.ip.address
Expected Output:
NRPE v2.12


19.Create NRPE Command Definition

nano /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$
}


20. Create Linux Object template
nano /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
}

21. Activate the linux-box-remote.cfg template
nano /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

22. Verify Nagios Config Files

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Expected Output:
Total Warnings: 0
Total Errors: 0

23. Restart Nagios Service
service nagios restart


Please check the Nagios website if any errors are encountered. This install went off relatively smoothly, no major errors.

Only the standatd NRPE plugins were demonstrated in this install, please visit the Nagios website for more plugins!

-n