Tuesday, 8 March 2016

Nagios Installation

Nagios is the most popular, open source, powerful monitoring system. It enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios has capability of monitoring application, services, entire IT infrastructure.

Install following dependencies

# yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp

Start http service

# service httpd start

Now create a new nagios user account and setup a password to this account

# useradd nagios
# passwd nagios

Now create a groud for nagios setup “nagcmd” and add nagios user to this group. Also add nagios user in apache group.

# groupadd nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

# cd /opt/
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.1.1.tar.gz
# tar xzf nagios-4.1.1.tar.gz
# cd nagios-4.1.1
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
Now use below command to setup apache configuration for Nagios installation.

# make install-webconf

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now restart Apache service to make the new settings take effect.

# service httpd restart

Nagios Plugins

# cd /opt
# wget http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
# tar xzf nagios-plugins-2.1.1.tar.gz
# cd nagios-plugins-2.1.1
Now compile and install nagios plugins

# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

Use the following commands to verify nagios install and start nagios core service.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios start
Also configure nagios service to start on system start

# chkconfig --add nagios
# chkconfig nagios on

Client side 

Nrpe configuration

Configuring The Init System For NRPE

Now that nrpe has been installed, we need to set up an init script/system for the agent. You will first need to Install xinetd. Most Linux
distributions include the package. As of the writing of this document, you can install nrpe on the following distributions, the following
ways:
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz

cd nrpe-2.14 ./configure make make install Copy over the nrpe.cfg from the sample-config directory into /usr/local/nagios/etc. mkdir /usr/local/nagios/etc cp sample-config/nrpe.cfg /usr/local/nagios/etc

CentOS/RHEL/Fedora$ yum install xinetd
Ubuntu/Debian$ apt-get install xinetd
Gentoo$ emerge -va xinetd
ArchLinux$ pacman -S xinetd

Once xinetd is installed, we must configure it. The nrpe source has a pre-built xinetd config for the nrpe service. Change directory to

the nrpe source and install it:

cd /tmp/nrpe-2.14
make install-xinetd

vim /etc/xinetd.d/nrpe
Change:
only_from = 127.0.0.1
To:
only_from = 127.0.0.1 x.x.x.x
(where x.x.x.x is your Nagios XI server's ip)


Finally, we need to add the nrpe port and service declaration in /etc/services:
nano /etc/services
Add:
nrpe 5666/tcp


Let's test nrpe/xinetd to make sure it starts up cleanly:

service xinetd start

cd /usr/local/nagios/libexec
./check_nrpe -H localhost

You should see the following output:
NRPE v2.14

No comments:

Post a Comment