You are on page 1of 22

NAGIOS INSTALLATION AND CONFIGURATION

PROJECT: ICOE INFRA TEAM

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 1 of 22

info@sdgc.com

Classification: GE Confidential

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 2 of 22

info@sdgc.com

Classification: GE Confidential

1.1 PURPOSE
This document states step by step procedures to install and configure nagios to monitor remote hosts.

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 3 of 22

info@sdgc.com

Classification: GE Confidential

1. WHAT IS NAGIOS?
.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. 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 Contact notifications when service or host problems occur and get resolved. Ability to define event handlers to be run during service or host events for proactive problem resolution.

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 4 of 22

info@sdgc.com

Classification: GE Confidential

INSTALLATION DETAILS
Install necessary packages:
yum install httpd gcc glibc glibc-common gd gd-devel php

Create Nagios User account and group


useradd -m nagios
Create nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user

groupadd nagcmd

usermod -a -G nagcmd nagios

GE Partner Program

usermod -a -G nagcmd apache

Create Directory to store Nagios installation files


mkdir /opt/Nagios

Download Nagios and Plugins


Save file to directory /opt/Nagios http://www.nagios.org/download/download.php As of this writing Nagios 3.0.6 (Stable) and Nagios Plugins 1.4.13 (Stable) Extract Files:

cd /opt/Nagios tar xvzf nagios-3.2.3.tar.gz

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 5 of 22

info@sdgc.com

Classification: GE Confidential

cd nagios-3.2.3

Compile and Configure Nagios

./configure --prefix=/opt/Nagios/ --with-command-group=nagcmd

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 6 of 22

info@sdgc.com

Classification: GE Confidential

make all

GE Partner Program

Compile binaries, init script, sample config files:

make install

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 7 of 22

info@sdgc.com

Classification: GE Confidential

make install-init make install-config

GE Partner Program

make install-commandmode
Nagios has now been installed to the directory /opt/nagios/ ** Do Not Start Nagios **

Install Nagios Web Interface:

make install-webconf

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 8 of 22

info@sdgc.com

Classification: GE Confidential

Now move this file to /opt/nagios/etc (To keep all the files of associated with nagios at a single location) cp /etc/httpd/conf.d/nagios.conf /opt/nagios/etc/ (Since we need apache for viewing the admin console, make an entry of nagios.conf in apache configuration file) Add the below lines Include /opt/Nagios/etc/nagios.conf Now Create Web Interface Login User:

GE Partner Program

Restart Apache:

service httpd restart

Install Nagios Plugins


Extract Files:

cd /opt/Nagios tar xzf nagios-plugins-1.4.15.tar.gz cd nagios-plugins1.4.15

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 9 of 22

info@sdgc.com

Classification: GE Confidential

Compile and Configure Nagios Plugins

./configure --prefix=/opt/Nagios/ --with-nagios-user=nagios --with-nagios-group=nagios


make make install

Verify the sample Nagios configuration files /opt/Nagios/bin/nagios -v /opt/Nagios/etc/Nagios.cfg /etc/init/d/nagios start

GE Partner Program

Access the Admin Console: Open the web browser Open the URL: http://localhost:80/nagios
(Local host: Host where Nagios is installed)

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 10 of 22

info@sdgc.com

Classification: GE Confidential

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 11 of 22

info@sdgc.com

Classification: GE Confidential

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 12 of 22

info@sdgc.com

Classification: GE Confidential

WHAT IS NRPE?
The NRPE add-on is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor "local" resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent likes NRPE must be installed on the remote Linux/Unix machines.

GE Partner Program
The NRPE add-on consists of two pieces: The check_nrpe plugin, which resides on the local monitoring machine The NRPE daemon, which runs on the remote Linux/Unix machine When Nagios needs to monitor a resource of service from a remote Linux/Unix machine. Nagios will execute the check_nrpe plugin and tell it what service needs to be checked The check_nrpe plugin contacts the NRPE daemon on the remote host over an (optionally) SSL-protected connection The NRPE daemon runs the appropriate Nagios plugin to check the service or resource The results from the service check are passed from the NRPE daemon back to the check_nrpe plugin, which then returns the check results to the Nagios process.

(Note: The NRPE daemon requires that Nagios plugins be installed on the remote Linux/Unix host. Without these, the daemon wouldn't be able to monitor anything.)
A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com Page 13 of 22

info@sdgc.com

Classification: GE Confidential

Installation of NRPE
Prerequisites

In order to complete this installation, you'll need: Root access on the remote Linux/Unix host Access to the nagios user account on the monitoring host

i.

Remote Host Setup

Create Account Information

GE Partner Program

Create a new nagios user account and give it a password.


/usr/sbin/useradd nagios passwd nagios

ii.

Install the Nagios Plugins Download the pluggins and nrpe file to /opt/nagios
mkdir /opt/Nagios cd /opt/Nagios

Extract the Nagios plugins source code tarball.


tar xzf nagios-plugins-1.4.6.tar.gz cd nagios-plugins-1.4.6

Compile and install the plugins ./configure --prefix=/opt/Nagios/ --with-nagios-user=nagios --with-nagios-group=nagios make make install chown nagios.nagios /opt/Nagios/

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 14 of 22

info@sdgc.com

Classification: GE Confidential

iii. iv.

Install xinetd Install the NRPE daemon

./configure --prefix=/opt/Nagios/ --with-nagios-user=nagios --with-nagiosgroup=nagios

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

GE Partner Program

vim /etc/xinetd.d/nrpe
A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com Page 15 of 22

info@sdgc.com

Classification: GE Confidential

Add the following entry for the NRPE daemon to the /etc/services file. nrpe 5666/tcp # NRPE Restart the xinetd service. service xinetd restart

GE Partner Program

Monitoring Host Setup


On the monitoring host (the machine that runs Nagios), you'll need to do just a few things: Install the check_nrpe plugin Create a Nagios command definition for using the check_nrpe plugin Create Nagios host and service definitions for monitoring the remote host Since we have already installed the plugin and nrpe, next we have to check the connectivity of the remote host with the Monitoring server.
/opt/nagios/libexec/check_nrpe -H 192.168.0.1 (Monitoring Server side) 192.168.0.1 --- Remote host to be monitored

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 16 of 22

info@sdgc.com

Classification: GE Confidential

Create a command definition You'll need to create a command definition in one of your Nagios object configuration files in order to use the check_nrpe plugin.
vi /opt/nagios/etc/commands.cfg

And add the following definition to the file:


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

Define the host

Firstly define the host in template.cfg. It contains parameters like check_period , check_interval .. Etc.

GE Partner Program
Now create a file hostgroups.cfg and define the hostgroups. vim /opt/Nagios/etc/objects/hostgroups.cfg

Create a customized location which would contain configuration details for all the hosts. mkdir /opt/nagios/etc/hosts

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 17 of 22

info@sdgc.com

Classification: GE Confidential

Create folders according to the hostgroups defined in hostgroups.cfg and define configuration files for all the hosts to be monitored. E.g. vim x.x.x.x.cfg

GE Partner Program
In the above configuration we have defined custom contact groups. To define custom contact groups, follow the below mentioned instructions: vim /opt/Nagios/etc/objects/contacts.cfg

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 18 of 22

info@sdgc.com

Classification: GE Confidential

GE Partner Program
Now we have to define the service groups for the services which are monitored vim /opt/Nagios/etc/objects/servicegroups.cfg

By defining the Service and host groups we can get an accumulated view of services and hosts monitored by Nagios Server.

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 19 of 22

info@sdgc.com

Classification: GE Confidential

GE Partner Program

Setup Remote Host for Monitoring


A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com Page 20 of 22

info@sdgc.com

Classification: GE Confidential

We need to to make some configurational changes at the remote host site to ensure that nagios server can fetch the desired data. We have already installed the plugin and nrpe at the remote. Now we need to define the services which will be monitored in the file nrpe.cfg. vim /opt/Nagios/etc/nrpe.cfg

The above screenshot displays the configuration which we need to define at the remote host end. command[check_users]=/opt/Nagios//libexec/check_users -w 5 -c 10

GE Partner Program

command[check_users] --------- This need to be same at the Nagios server end as well. These entries can be located under the configuration files for the remote host. /opt/Nagios//libexec/check_users --- Path of the script which will perform the check. -w 5 -c 10 ------- These entries define the threshold values. W and C are for warning and critical respectively.

Now run the below mentioned command to verify the configuration


A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com Page 21 of 22

info@sdgc.com

Classification: GE Confidential

/opt/Nagios/bin/nagios -v /opt/Nagios/etc/Nagios.cfg /etc/init/d/nagios restart

GE Partner Program

A-10, Sector 2 Noida UP 201301 Tel. +91.120.4014000 Fax. +91.120.4014020 www.sdgc.com

Page 22 of 22

info@sdgc.com

Classification: GE Confidential

You might also like