Howto install nagios on centos/fedora/Redhat

Mar-24th-2010

Hi,

Today I was hunting about monitoring tool in linux and found lots of monitoring tools (i.e. Nagios, openNMS, Cacti 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@map007]# yum install httpd

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

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

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

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

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

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

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

[root@map007]#  useradd  nagios

[root@map007]#   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@map007]# groupadd  nagcmd

[root@map007]# usermod –a –G  nagcmd nagios

[root@map007]# usermod –a –G nagcmd apache

Now download Nagios and Nagios-Plugins :-

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

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

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

[root@map007]#  cd  nagios-3.2.1

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

[root@map007]#  make all

[root@map007]#  make install

[root@map007]# make install-init

[root@map007]# make install-config

[root@map007]# make install-commandmode

[root@map007]# make install-webconf

(it will create nagios web config file in apache conf.d direcotry)

Now create nagiosadmin account for nagios web interface.

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

Password:

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

Now install nagios-plugin.

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

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

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

[root@map007]# make

[root@map007]# make install

Now you have installed all the required packages and services.

Now start nagios.

[root@map007]#  chkconfig  –add nagios

[root@map007]#  chkconfig nagios on

Verify your nagios config file.

[root@map007]#  /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@map007]#  /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@map007~]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz


Extract the Files:


[root@map007~]# tar -xzf nrpe-2.12.tar.gz
[root@map007~]# 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@map007~]# ./configure

General Options:

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

[root@map007~]# make all

[root@map007~]# make install-plugin

[root@map007~]# make install-daemon

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

[root@map007~]# make install-xinetd



Post NRPE Configuration

Edit Xinetd NRPE entry:

Add Nagios Monitoring server to the “only_from” directive



[root@map007~]# 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 <nagios_ip_address, replace the 127.0.0.1 with the nagios server ip or comment it>



Edit services file entry:

Add entry for nrpe daemon



[root@map007~]# vi /etc/services

nrpe 5666/tcp # NRPE

Restart Xinetd and Set to start at boot:



[root@map007~]# chkconfig xinetd on

[root@map007~]# service xinetd restart


Test NRPE Daemon Install

Check NRPE daemon is running and listening on port 5666:



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

Output should be:-

tcp 0 0 *:nrpe *.* LISTEN

or

[root@map007]# 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@map007]# /usr/local/nagios/libexec/check_nrpe -H localhost

Output should be NRPE version:

NRPE v2.12


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

Enjoy Linux !!!


Mega World News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon Weekend Joy

Comments

  1. vaibhav Said,

    helpful one

  2. seomoz Said,

    Hi, colleague! I like your blog, it’s so interesting! I think it’s pretty popular, isn’t it? I would like to invite you to my favorite Pay-Per-Click system, I believe you can earn with your blog a lot here. My crazy russian friend earns $3.000 per day here! Look, it doesn’t obligate you to anything http://klikvip.com/landings/en/landing2/index.php?aff=35357

  3. ishika chopra Said,

    Hi ,
    Can u suggest how to install some other better monitering tool then this …..

  4. map007 Said,

    Hi,

    Give me your tool name which you want to install….

  5. Njupi Said,

    it was very interesting to read.
    I want to quote your post in my blog. It can?
    And you et an account on Twitter?

  6. Lindsay Said,

    Thanks so much for posting all of the excellent information! Looking forward to checking out more posts.

  7. Nishant Said,

    can u suggest step by step how to install zenoss on centos 5.4 thanks in advance. i will wait your valuable replay.

  8. piyushmap Said,

    Hi Nishant,

    I will definitely update Zenoss installation on my blog….. And if you need urgent then you can follow this.

    Thanks for visiting my blog.

  9. Nishant Said,

    your documentation is very nice. thanks a lot for this documentation.

    i have another question.i deployed qmail server i am facing problems in L user relay. how to set L user relay.can u help me in that problem.i will wait for your valuable reply .

  10. prabhat Said,

    hi every one

    any one of you knows to install monitoring tools for vsftpd …………
    if any knows then please tell………………………..
    thanks in advance……………

  11. piyushmap Said,

    Hi,

    If you just want to monitor ftp service, then you can install check_ftp plugin in nagios and monitor your ftp service.

    For more check_ftp details check this link :- http://nagiosplugins.org/man/check_ftp

  12. prabhat Said,

    hi, piyushmap

    can u tell another tools except nagios to monitor ftp log on frontend …………….

    i mean to see graphicaly ………………………….

    like monitorx is a very good tool

  13. vivek pal Said,

    hi every

    hi do u know any tool to watch ftp xferlog on frontend except nagios……….
    i will wait your reply

    thanks every one……..

  14. piyushmap Said,

    Hi,

    You can use Hyperic and zabbix instead of nagios.
    Hope this will help you.

    Thank you.

  15. piyushmap Said,

    Hi Vivek,

    You can use Hyperic and zabbix instead of nagios.
    Hope this will help you.

    Thank you.

  16. nishant Said,

    hi piyushmap sir,

    i want to configure sendmailanalyzer……….please can u tell how to install sendmailanalyzer on centos 5.4 step by step………..thanks
    i will wait for your reply……….
    nishant….

  17. prabhat Said,

    hi piyus

    your documentation is nice but. i want to install ” ispCP Omega | ISP ” on centos 5.4 ..
    is there any documentation…..if u have …then mail me linuxprabhat@gmail.com

    thanks
    regards
    prabhat kumar

  18. nutricionista online Said,

    Simply briliant!…

    Just love your writing style….

  19. Coping Skills Said,

    A Hoot…

    I saw this pretty great post now….

  20. Fife Holiday Said,

    Move Quick…

    You should see this awesome information which we just saw….

Add A Comment

*