Nagios Installation on Centos-Fedora-Redhat

Firstof all you have to install apache, php and xinetd. If those are installed previously just skip this step, and also check xinetd is already installed or not by typing chkconfig –list xinetd.

yum install httpd php gd gd-devel gcc glibc glibc-common openssl-devel xinetd perl

Download latest Nagios core, Nagios plug-ins and nrpe from http://prdownloads.sourceforge.net/sourceforge/nagios/ http://prdownloads.sourceforge.net/sourceforge/nagiosplug/

create a new user for Nagios and setup a password, note that do not just use a password like Nagios, use a bit secure password for that user or just change login to nologin by editing /etc/passwd file

useradd -m nagios
passwd nagios


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


extract nagios and configure source for compilation

tar zxvf nagios-3.2.3.tar.gz
cd  nagios-3.2.3
./configure –with-command-group=nagcmd


make and install nagios
make all
make install
make install-init
make install-config
make install-commandmode


open contacts.cfg and fill up the details

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

make install-webconf

setup a password for nagios web administrator, nagiosadmin is the user name and you can use your own user name here

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

extract nagios-plugins and configure the source

tar zxvf nagios-plugins-1.4.15.tar.gz
cd  nagios-plugins-1.4.15
./configure --with-nagios-user=nagios –with-nagios-group=nagios


make and install
make
make install


then add nagios and apache to startup script to auto start on system startup

chkconfig --add nagios
chkconfig nagios on
chkconfig --add httpd
chkconfig httpd on


service httpd start
service nagios start


Client Machine Preparation

Add a user for nagios, and setup a password. Use a secure password or set the user to nologin. Using nologin is preferable than using a secure password because with nologin, user login will be disabled for the nagios user.

useradd nagios
passwd nagios

check xinetd is installed,
chkconfig --list xinetd

if not install it,
yum install openssl-devel xinetd

download latest nagios-plugins from http://prdownloads.sourceforge.net/sourceforge/nagiosplug/ and extract the source, goto extracted source folder and configure the source for compilation

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

make and install
make
make install

change the ownership of the nagios installation folder to nagios user if it is not set,

chown -R nagios.nagios /usr/local/nagios/

download nrpe nagios plug-in from http://prdownloads.sourceforge.net/sourceforge/nagios/, and extract it

tar zxvf nrpe-2.12.tar.gz
configure the source for compilation

cd  nrpe-2.12
./configure

if the configuration is successful you will see a output like below,
General Options:
-------------------------
NRPE port:    5666
NRPE user:    nagios
NRPE group:   nagios
Nagios user:  nagios
Nagios group: nagios


then make and install nrpe
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd


open /etc/xinetd.d/nrpe file and add the nagios server ip address for the only_from option
eg: only_from = 127.0.0.1 147.120.100.1

open /etc/services and add nrpe port 5666
nrpe      5666/tcp    # NRPE port user for nagios access

add xinetd to autostart and restart it

chkconfig xinetd on
service xinetd restart


now the nagios client configuration is finished, you can check the functionality by issuing a nrpe check command from nagios server

eg: /usr/local/nagios/libexec/check_nrpe -H <nagios client ip>
 
you will get a output of the installed nrpe version.

0 comments: