Nagios_logo_black

Nagios  is a system and network monitoring application. It watches hosts and services that you specify,alerting you when things go bad and when they get better.Nagios was originally designed to run under linux,although it should work under most other unices aswell.

 

 

Some of the many features of Nagios include:

  • Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)

 

  • Monitoring of host resources (processor load, disk usage, etc.)

 

  • Simple plugin design that allows users to easily develop their own service checks

 

  • Parallelized service checks

 

  • Ability to define network host hierarchy using “parent” hosts, allowing detection of and distinction between hosts that are down and those that are unreachable

 

  • Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)

 

  • Ability to define event handlers to be run during service or host events for proactive problem resolution

 

  • Automatic log file rotation

 

  • Support for implementing redundant monitoring hosts

 

  • Optional web interface for viewing current network status, notification and problem history, log file, etc.

 

 

#yum install httpd php gcc glibc glibc-common gd ggd-devel

 

Creating nagios user

 

#useradd –m nagios

#passwd nagios

 

Add nagcmd group

 

#groupadd nagcmd

#usermod –a –G nagcmd nagios

#usermod  -a  -G  nagcmd apache

 

Now go to http://www.nagios.org download files

Nagios-3.4.3.tar.gz    nagios-plugins-1.14.16.tar.gz   nrpe-12.2.tar.gz

 

 

#tar –xzvf nagios-3.4.3.tar.gz

#cd nagios-3.4.3

#./configure  -with-nagios-user=nagios  –with-nagios-group=nagios

#make all;make install;make install-init;make install-config;make install-commandmode;make install-webconf

1

2

Edit your email admin address

 

#vi /usr/local/nagios/etc/objects/contacts.cfg

email                      sathish@sathish.com

3

Create a nagiosadmin account for logging into the nagios web interface assign to this you’ll need it later

 

#htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin

 

#service httpd restart

 

 

Extract and install nagios- plugins

#tar  -xzvf  nagios-plugins-1.14.16.tar.gz

#cd nagios-plugins

#./configure  –with-nagios-user=nagios  –with-nagios-user=nagios

#make;make install

 

4

5

#chkconfig  –add nagios

#chkconfig nagios on

 

 

Verify if you have a good config of nagios  with the command

#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg

 

6

Check if there is no error displayed; then start the nagios service

#service nagios start

7 8

 

Installation NRPE  and Setup:-

#tar –xzf nrpe-2.12.tar.gz
#cd nrpe-2.12

# ./configure

#make all;make install-plugin;make install-daemon;make install-daemon-config;make install-xinetd

10 12

 

Add Nagios Monitoring server ip to the “only_from” directive
or comment it

 

# vi /etc/xinetd.d/nrpe

service nrpe
{
flags           = REUSE
socket_type     = stream
port            = 5666
wait            = no
user            = nagios
group           = nagios
server          = /usr/local/nagios/bin/nrpe
server_args     = -c /etc/nrpe.conf –inetd
log_on_failure  += USERID
disable         = no
#only_from       = 127.0.0.1
}
 

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

 

Testing NRPE Daemon 

Check NRPE daemon is running and listening on port 5666:

 

# netstat -at |grep nrpe

Output should be:-

tcp 0 0 *:nrpe *.* LISTEN

 

# netstat -plan | grep 5666

tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      15721/xinetd

 

Check NRPE daemon is functioning:

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

NRPE v2.12

 

13 13

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.

 

 

Open the file /usr/local/nagios/etc/objects/commands.cfg and add the following entry to it.

#vi /usr/local/nagios/etc/objects/commands.cfg

define command{
command_name    check_nrpe
command_line    /usr/local/nagios/libexec/check_nrpe  -H  $HOSTADDRESS$ -c $ARG1$
}

 

13a

Client side (To monitor a remote client)

Use th NRPE daemon to execute Nagios plugins on the remote server and report back to the monitoring host server.

 

 

Create Nagios user account on the client :

# useradd nagios
# passwd nagios

 

Download and Install Nagios Plugins:

#tar xzf nagios-plugins-1.4.14.tar.gz

#cd nagios-plugins-1.4.14.tar.gz

 

Compile and Configure Nagios 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

 

Install the xinetd Package

# yum install xinetd

23

Downlad and Install NRPE Daemon

#tar -xzf nrpe-2.12.tar.gz

# cd nrpe-2.12

 

Compile and Configure NRPE

# ./configure

#make all;make install-plugin;make install-daemon;make install-daemon-config;make install-xinetd

25

 

NRPE Configuration

Edit Xinetd NRPE entry:

Add Nagios Monitoring server ip to the “only_from” directive  or   comment it

# vi /etc/xinetd.d/nrpe

Entry will be like this:-

service nrpe26
{
flags           = REUSE
socket_type     = stream
port            = 5666
wait            = no
user            = nagios
group           = nagios
server          = /usr/local/nagios/bin/nrpe
server_args     = -c /etc/nrpe.conf –inetd
log_on_failure  += USERID
disable         = no
#       only_from       = 127.0.0.1
}

 

# vi /etc/services

nrpe 5666/tcp # NRPE

 

#chkconfig xinetd on

#service xinetd restart

 

Open Port 5666 on Firewall

 

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
# netstat -plan | grep 5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      15721/xinetd

Check NRPE daemon is functioning:

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

NRPE v2.12

 

27

#vi /etc/nrpe.conf

 

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 5,100,100 -c 10,100,100
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_procs]=/usr/local/nagios/libexec/check_procs -w 500 -c 1000
command[check_cron]=/usr/local/nagios/libexec/check_procs -w 1:5 -c 1:20 -C crond
command[check_mem]=/usr/local/nagios/libexec/check_mem -w 90 -c 95
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 10% -c 5%

28

Test Connection to NRPE daemon on Remote Server:-

Make sure that the NRPE on ther Nagios server can talk to the NRPE daemon on the remote server (Client) we want to monitor.
Execute the command:-

 

# /user/local/nagios/libexec/check_nrpe -H <IP of Remote Server>
NRPE v2.12

 

 

From the Server side:

create the files /usr/local/nagios/etc/objects/hosts.cfg ,/usr/local/nagios/etc/objects/servicess.cfg manually & add it into /usr/local/nagios/etc/nagios.cfg as follows .

#vi /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg

 28a

# vim /usr/local/nagios/etc/objects/hosts.cfg

Add the clientside details along with the server side details , for example consider the following;

 

#For Server side

define hostgroup{

hostgroup_name nagios

alias Nagios Administrators

members http://www.sathish.com

}

define host{

use generic-host ; Name of host template to use

host_name  www.sathish.com

alias Nagios Administrators

address 192.168.31.1

check_command check-host-alive

max_check_attempts 3

notification_interval 300

notification_period 24x7_sans_holidays

notification_options d,u,r

contact_groups admins

}

#For client side

define hostgroup{

hostgroup_name client

alias arthar2

members arthar2.sathish.com

}

define host{

use generic-host ; Name of host template to use

host_name arthar2.sathish.com

alias arthar2

address 192.168.31.150

check_command check-host-alive

max_check_attempts 3

notification_interval 300

notification_period 24x7_sans_holidays

contact_groups              admins

 

29

# vim /usr/local/nagios/etc/objects/services.cfg

# Service definition

define service{

use         generic-service

#   host_name       arthar2.sathish.com

hostgroup_name    nagios

service_description     PING

check_command           check_ping!200.0,20%!600.0,60%

check_interval          10

is_volatile              0

retry_interval          1

max_check_attempts      5

check_period            24×7

process_perf_data       0

notification_interval         300

notification_period         24×7

notification_options         c

#contact_groups               admin

}

 

define service {

use                     generic-service

#    host_name               arthar2.sathish.com

hostgroup_name        client

service_description     PING

check_command           check_ping!200.0,20%!600.0,60%

check_interval          10

is_volatile              0

retry_interval          1

max_check_attempts      5

check_period            24×7

process_perf_data       0

notification_interval         300

notification_period         24×7

notification_options         c

contact_groups             admins

 

 

 

}

define service{

use         generic-service

#   host_name       arthar2.sathish.com

hostgroup_name    client

service_description   SSH

check_command           check_ssh

check_interval          10

is_volatile              0

retry_interval          1

max_check_attempts      5

check_period            24×7

process_perf_data       0

notification_interval         300

notification_period         24×7

notification_options         c

contact_groups               admins

}

define service{

use         generic-service

#host_name    arthar2.sathish.com

hostgroup_name   client

service_description   HOSTALIVE

check_command         check-host-alive

check_interval          10

is_volatile              0

retry_interval          1

max_check_attempts      5

check_period            24×7

process_perf_data       0

notification_interval         300

notification_period         24×7

notification_options         c

contact_groups               admins

}

define service{

use         generic-service

hostgroup_name    client

#host_name    arthar2.sathish.com

service_description   HTTP

check_command         check_http

check_interval          10

is_volatile              0

retry_interval          1

max_check_attempts      5

check_period            24×7

process_perf_data       0

notification_interval         300

notification_period         24×7

notification_options         c

contact_groups               admins

}

30

#service nagios restart

#chkconfig nagios on

login in to your browser

http://www.sathish.com/nagios

33 34 35