Nagios Server Configuration
Nagios Server Configuration
1) wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
2) rpm ivh epel-release-5-4.noarch.rpm
3) yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp
4) Download NAGIOS CORE Server Software
5) wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.6.tar.gz
6) tar xvf nagios-4.0.6.tar.gz
7) cd nagios-4.0.6
8) useradd nagios
9) passwd nagios
10)
groupadd nagcmd
11)
usermod -a -G nagcmd nagios
12)
./configure --with-command-group=nagcmd
13)
make all
14)
make install
15)
make install-init
16)
make install-config
17)
make install-commandmode
18)
make install-webconf
19)
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
20)
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
21)
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
22)
/etc/init.d/nagios restart
23)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Install the NRPE plugin (for testing), daemon, and sample daemon config file.
make install-plugin
make install-daemon
make install-daemon-config
Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.
Add the following entry for the NRPE daemon to the /etc/services file.
nrpe 5666/tcp # NRPE
The output out above command should show something like this:
tcp 0 0 *:nrpe *:* LISTEN
Next, check to make sure the NRPE daemon is functioning properly. To do this, run the check_nrpe plugin that was
installed
for testing purposes.
/usr/local/nagios/libexec/check_nrpe -H localhost
You should get a string back that tells you what version of NRPE is installed, like this:
NRPE v2.8
On nagios server,after installtion of nrpe ,nrep service is not created default ,you need to create it with usign
below steps
cd /root/nrpe-2.12
cp init-script /etc/init.d/nrpe
chmod 777 /etc/init.d/nrpe
/etc/init.d/nrep restart
log_facility=daemon
pid_file=/var/run/nrpe/nrpe.pid
server_port=5666
nrpe_user=nrpe
nrpe_group=nrpe
allowed_hosts=192.168.10.50 (Nagios server ip address)
dont_blame_nrpe=0
debug=0
command_timeout=60
connection_timeout=300
include_dir=/etc/nrpe.d/
Defult :command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1 (Enter here / partition device name for eg:
/dev/had1)
command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
change to :-
command[check_users]=/usr/lib/nagios/plugins/check_users -w 80 -c 90
command[check_http]=/usr/lib/nagios/plugins/check_http -H 127.0.0.1 -w 2 -c 1
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh -t 30 -H 10.20.41.250
command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20% -c 10%
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda2
command[check_procs]=/usr/lib/nagios/plugins/check_procs -w 190 -c 220
command[check_ping]=/usr/lib/nagios/plugins/check_ping -H 10.20.41.250 -w 100.0,25% -c 300.0,75% -p 1
NOTE:-1).when you install Nagios plugines through YUM command then nagios plugines install at path
/usr/lib/nagios/plugins/ on 32 bit os ,on 64 bit os /usr/lib64/nagios/plugins/
2). when you install Nagios pluginess through source means download nagios plugine and install ,then that
time Nagios plugines install at path /usr/local/nagios/libexec
11)
/etc/init.d/nrpe restart
useradd nagios
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
passwd nagios
Download Nagios Plugin
wget http://nagios-plugins.org/download/nagios-plugins-2.0.2.tar.gz
tar xvf nagios-plugins-2.0.2.tar.gz
cd nagios-plugins-2.0.2
./configure --with-nagios-user=nagios --with-nagios-group=nagios
Make
Make install
generic-service.
#
#
# 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
host_name
GLPI_Server
alias
GLPI_Server
address
192.168.10.21
}
############################################################################
##
############################################################################
##
# 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
kaushik_server Comma separated list of hosts that belong to this group
}
##########################################################################
############################################################################
#
# SERVICE DEFINITIONS
############################################################################
##
############################################################################
##
# Define a service to "ping" the local machine
define service{
use
generic-service
; Name of service template to use
host_name
GLPI_Server
service_description
PING
check_command
check_nrpe!check_ping
}
##############################################################################
#
##############################################################################
#
# Just one contact defined by default - the Nagios admin (that's you)
# This contact definition inherits a lot of default values from the 'generic-contact'
# template which is defined elsewhere.
define contact{
contact_name
use
alias
nagiosadmin
generic-contact
Nagios Admin
email
}
##############################################################################
#
/etc/init.d/nagios restart
Host: localhost
Address: 127.0.0.1
State: CRITICAL
Date/Time: Fri Jun 6 11:14:17 EDT 2014
Additional Info:
DISK CRITICAL - free space: / 23295 MB (5% inode=94%):
-------------------------------------------------------------------------------------------While Reseduling/Refteshing any service if you get the Below error
----------------------------------------------------------------------------------------Error: Could not open command file '/usr/local/nagios/var/rw/nagios.cmd' for update!
The permissions on the external command file and/or directory may be incorrect. Read the FAQs on how to setup proper
permissions.
An error occurred while attempting to commit your command for processing.
Return from whence you came
Soution is Below
Go to the below path on Nagios server
#/usr/local/nagios/var/rw/
Change the permission of nagios.cmd file as below
#chmod 777 nagios.cmd