Skip to content


How to install Nagios on Redhat/fedora/CentOS..

Hi,

Today I was hunting about monitoring tool in linux and found lots of monitoring tools (i.e. Nagios, openNMS, Cacti,Centreon etc..) And I try to install nagios. You can also install nagios by following steps :-

Prerequisites:

1. Apache
2. PHP
3. GCC compiler
4. GD development libraries
5. PERL Modules
6. RRDTOOL

And you can install these packages through yum:-

[root@p-root]# yum install httpd

[root@p-root]# yum install php php-mysql php-gd php-ldap php-xml

[root@p-root]# yum install gd gd-devel

[root@p-root]# yum install gcc glibc glibc-common libstdc++-devel gcc-c++

[root@p-root]# yum install install perl-DBI perl-DBD-MySQL

[root@p-root]# yum install install perl-Config-IniFiles

[root@p-root]# yum install install rrdtool perl-rrdtool

Now create new nagios user account and give it password….

[root@p-root]# useradd nagios

[root@p-root]# passwd nagios

Now create nagcmd group for external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

[root@p-root]# groupadd nagcmd

[root@p-root]# usermod –a –G nagcmd nagios

[root@p-root]# usermod –a –G nagcmd apache

Now download Nagios and Nagios-Plugins :-

[root@p-root]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz

[root@p-root]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

[root@p-root]# tar –zxvf nagios-3.2.1.tar.gz

[root@p-root]# cd nagios-3.2.1

[root@p-root]# ./configure – -with-command-group=nagcmd

[root@p-root]# make all

[root@p-root]# make install

[root@p-root]# make install-init

[root@p-root]# make install-config

[root@p-root]# make install-commandmode

[root@p-root]# make install-webconf

(it will create nagios web config file in apache conf.d direcotry)
Now create nagiosadmin account for nagios web interface.

[root@p-root]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Password:

[root@p-root]# /etc/init.d/httpd restart

Now install nagios-plugin.

[root@p-root]# tar –zxvf nagios-plugins-1.4.11.tar.gz

[root@p-root]# cd nagios-plugins-1.4.11

[root@p-root]# ./configure –with-nagios-user=nagios –with-nagio-group=nagios

[root@p-root]# make

[root@p-root]# make install

Now you have installed all the required packages and services.
Now start nagios.

[root@p-root]# chkconfig –add nagios

[root@p-root]# chkconfig nagios on

Verify your nagios config file.

[root@p-root]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there is no error it means your nagios configuration is correct and you can start nagios service.

[root@p-root]# /etc/init.d/nagios start

Now access your nagios web interface :-

http://localhost/nagios

==============================================

NRPE Installation and Setup:-

Download and Install NRPE

You may download nrpe from http://www.nagios.org/download/download.php

[root@p-root~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

Extract the Files:

[root@p-root~]# tar -xzf nrpe-2.12.tar.gz
[root@p-root~]# cd nrpe-2.12

Compile and Configure NRPE

You need the openssl-devel package installed to compile NRPE with ssl support. So make sure that open ssl is already installed on the server.

Install NRPE:

[root@p-root~]# ./configure

General Options:

————————-
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios

[root@p-root~]# make all

[root@p-root~]# make install-plugin

[root@p-root~]# make install-daemon

[root@p-root~]# make install-daemon-config

[root@p-root~]# make install-xinetd

Post NRPE Configuration

Edit Xinetd NRPE entry:

Add Nagios Monitoring server to the “only_from” directive

[root@p-root~]# vi /etc/xinetd.d/nrpe

Entry will be like this:-

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
}

only_from = 127.0.0.1

Edit services file entry:

Add entry for nrpe daemon

[root@p-root~]# vi /etc/services

nrpe 5666/tcp # NRPE

Restart Xinetd and Set to start at boot:

[root@p-root~]# chkconfig xinetd on

[root@p-root~]# service xinetd restart

Test NRPE Daemon Install

Check NRPE daemon is running and listening on port 5666:

[root@p-root~]# netstat -at |grep nrpe

Output should be:-

tcp 0 0 *:nrpe *.* LISTEN

or

[root@p-root]# netstat -plan | grep 5666

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

Check NRPE daemon is functioning:

[root@p-root]# /usr/local/nagios/libexec/check_nrpe -H localhost

Output should be NRPE version:

NRPE v2.12

======================================================================

Enjoy Linux !!!

Posted in Monitoring Tool, Open Source Applications.

Tagged with , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.