centostricks

Just another WordPress.com site

Nagios Server Installation


1.0 Installing and Configuring Nagios Server

1.1  Nagios Requirement

  •       Apache
  •       Gcc Compiler
  •       GD development libraries
  •       User  and Group nagios
  •       nagcmd group
  •       Openssl-devel
  •       xinetd

1.2 User and Group

# useradd  nagios

# groupadd nagcmd

#  usermod -G nagcmd nagios

# usermod -G nagcmd apache

# chown –R nagios:nagios /home/nagios

1.3 Installing Apache

# yum install httpd

# yum install php

# yum install mod_ssl

1.4 Installing GCC

# yum install gcc  ( This will installs  glibc,  glibc-common also)

1.5 Installing GD Tools

# yum install gd gd-devel

1.6 Installing Openssl

# yum install openssl-devel

1.7 Installing xinetd if not already installed

# rpm -qa xinetd   — > to verify if xinetd is already  installed , if the command doesn’t return anything we need to install it!

# yum install xinetd

2.0 Download  Nagios  and plugins on Nagios Server

# mkdir /home/nagios/downloads

# cd /home/nagios/downloads

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz

# wget  http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

2.1 Installing the Nagios Package

# tar zxvf nagios-3.2.0.tar.gz

# cd nagios-3.2.0

# ./configure –with-command-group=nagcmd

# make all

#  make install

# make install-init

# make install-config

# make install–commandmode

# make install-webconf

2.2 Now create nagiosadmin account for logging into nagios through web.

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

2.3 Compile and Install the Nagios Plugins

# cd /home/nagios/downloads

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

# cd nagios-plugins-1.4.14

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

# make

# make install

2.4 Configuring Nagios to Start at Bootup

# chkconfig  –add nagios

# chkconfig –level 345 nagios on

2.5 Editing Contacts in Contacts.cfg

# vi /usr/local/nagios/etc/objects/contacts.cfg  ( Change the e-mail address)

define contact{

contact_name       nagiosadmin             ; Short name of user

use                             generic-contact         ; Inherit default values from generic-contact template (defined above)

alias                           Nagios Admin            ; Full name of user

email                          <Email ID>      ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

}

2.6 Customizing the Subject Line in Nagios Alerts

vi /usr/local/nagios/etc/objects/command.cfg (change the Subject Format as highlighted)

notify-host-by-email /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /bin/mail -s “NAG_$ HOSTALIAS$ is $HOSTSTATE$” $CONTACTEMAIL$
notify-service-by-email /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” | /bin/mail -s “NAG_$HOSTALIAS$_$SERVICEDESC$ is $SERVICESTATE$” $CONTACTEMAIL$

2.7 Verify nagios configuration for any errors

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

If you don’t find any errors start nagios daemon

# service nagios start  or /etc/init.d/nagios start

2.8 Accessing the Login Page

Check the nagios URL in web browser and login with nagiosadmin.

http://servername/nagios (Example: http://nagiosserver/nagios)

Login using nagiosadmin user and its associated password.

2.9 Installing NRPE on Nagios server

NRPE  is an client plugin, which will communicate server through 5666. Nagios server also requires NRPE plugin.

# cd /home/nagios/downloads

# wget  http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

# tar zxvf nrpe-2.12.tar.gz

# cd nrpe-2.12

# ./configure –enable-ssl

# make all

# make install-plugin

# make install-daemon

# make install-daemon-config

# make install-xinetd

2.9.1 Edit /etc/service and add following

nrpe                       5666/tcp                               # NRPE

2.9.2 Edit  /etc/xinetd.d/nrpe and add nagios server IP or name

only_from = 127.0.0.1 <nagios_ip_address>

2.9.3 Restart xinetd and set to start at boot

#chkconfig –level 345 xinetd on

# service xinetd restart

2.9.4 Add the following in /usr/local/nagios/etc/objects/commands.cfg


##################################################################
# 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$
        }

2.9.5 Test NRPE daemon install and function:

# netstat –at |grep nrpe

tcp    0    0 *:nrpe    *.*    LISTEN

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

NRPE v2.12

2.9.6 Now check for local host in nagios server url

You should be all set with you new Nagios Server🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: