Adding Linux host to nagios server
Following flow summarizes the above explanation:
Nagios Server (check_nrpe) —–> Remote host (NRPE deamon) —–> check_disk
Nagios Server (check_nrpe) <—– Remote host (NRPE deamon) <—– check_disk (returns disk space usage)
1. How to add Linux client to the Nagios server
To start , In the remote host add nagios user,
# /usr/sbin/useradd nagios
# passwd nagios
We need two packages. Nagios-plugin and Nrpe
---> nagios-plugins-1.4.13.tar.gz ---> nrpe-2.12.tar.gz
# cd /home/nagios/nagios-plugins-1.4.15
# ./configure
# make
# make install
The permissions on the plugin directory and the plugins will need to be fixed at this point, so run the following commands.
# chown nagios.nagios /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios/libexec
2.Install XINETD
# yum install xinetd
Install the NRPE ( Nagios Remote Plugin Executor ) daemon
Nagios Remote Plugin Executor (NRPE) is a Nagios agent that allows remote systems monitoring using scripts that are hosted on the remote systems. It allows for monitoring resources such as disk usage, system load or number of users currently logged in. Nagios periodically polls the agent on the remote system using the check_nrpe plugin.
The NRPE-plugin is running as a xinetd-service.
# wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
# cd /home/nagios/nrpe-2.12/
# ./configure
# make all
Install the NRPE plugin (for testing), daemon, and sample daemon config file.
# make install-plugin
# make install-daemon
# make install-daemon-config
Install the NRPE daemon as a service under xinetd
# cd /home/nagios/nrpe-2.12/
# make install-xinetd
Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.
# vim /etc/xinetd.d/nrpe
only_from = 127.0.0.1 192.168.1.67 ------- nagios monitoring server ip
Add the following entry for the NRPE daemon to the /etc/services file.
# vim /etc/services
nrpe 5666/tcp # NRPE
Restart the xinetd service.
# service xinetd restart
Test the NRPE daemon locally
Its time to see if things are working properly. Make sure the nrpe daemon is running under xinetd.
# netstat -at | grep nrpe
The output out this command should show something like this:
tcp 0 0 *:nrpe *:* LISTEN
3. Now back to your Nagios Server, and Install NRPE deamon
# cd /home/nagios/nrpe-2.12/
# ./configure
# make all
Install the NRPE plugin
# make install-plugin
check of nrpe is working we will check the nrpe in the remote host
# /usr/local/nagios/libexec/check_nrpe -H 192.168.1.240
in server machine, give the ip of remote machines, to check whether they are communicating or not.
NRPE v2.12
Now in the nagios server : Go to
# cd /usr/local/nagios/etc/objects/
# cp localhost.cfg remotehost.cfg
# mv localhost.cfg Nagios-Server.cfg
Open remotehost.cfg and edit the hostname and IP adress
# vim remoteost.cfg
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 192.168.1.240
}
save and exit
# cd /usr/local/nagios/etc
# vim nagios.cfg
# Definitions for monitoring the local (Linux) host --------> add and comment lines below this
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg
save and exit
edit remotehost.cfg file
# cd /usr/local/nagios/etc/objects/
# vim /usr/local/nagios/etc/objects/remotehost.cfg
# Define a host for the local machine
define host{
use linux-server
host_name cloudcc.ctechz.blogspot.com
alias localhost
address 127.0.0.1
}
define host{
use linux-server
host_name www.ctechz.com
alias ctechz
address 192.168.1.240
}
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members cloudcc.ctechz.blogspot.com,www.ctechz.com
}
# SERVICE DEFINITIONS
define service{
use local-service
host_name cloudcc.ctechz.blogspot.com,www.ctechz.com
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
Add the Rest of the services like this
now check if you nagios server nagios can start without errors
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If no Errors found while running above command then restart the nagios.
# service nagios restart
http://192.168.1.67/nagios/
Uname : nagiosadmin
Passwd: redhat
No comments:
Post a Comment