Tuesday, 6 August 2013

Installing Nagios Server (4.0.0) on CentOS/RHEL 6.3

Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers.
This tutorial shows how to install Nagios 4.0.0-beta on CentOS/RHEL 6.3.

1) Prerequisites

After installing your CentOS/RHEL server, you have to install dependent packages to make nagios work.
   yum install httpd php gcc glibc glibc-common gd gd-devel openssl-devel 

2) Create nagios user and group by which we will be installing nagios

   useradd -m nagios
   passwd nagios
   groupadd nagcmd
   usermod -a -G nagcmd nagios
   usermod -a -G nagcmd apache

3) Installation

a) Create a directory where you would download nagios software:
   mkdir /opt/nagios
   cd /opt/nagios
b) Download nagios-core package/Untar/Compile and Install all necessary files for Nagios:
   wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.0/nagios-4.0.0-beta1.tar.gz
   tar -xzvf nagios-4.0.0-beta1.tar.gz
   cd nagios
   ./configure --with-command-group=nagcmd --with-httpd-conf=/etc/httpd/conf.d --with-init-dir=/etc/init.d/
   make all
   make install
   make install-init
   make install-commandmode
   make install-config
   make install-webconf
   make install-exfoliation

Note: By default nagios install itself in /usr/local/nagios

c) Create a password to log into the web interface:
   htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
d) Restart the httpd server:
   service httpd restart
e) Now we have to make nagios service to start automatically on boot using chkconfig:
   chkconfig --add nagios
   chkconfig nagios on
f) Verify if you have a good config of nagios with the command:
   /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
g) Check if there are no errors displayed; then start nagios with command:
   service nagios start
h) Now, we have to Download/Untar/Compile and Install all necessary files for Nagios-Plugin:
   cd /opt/nagios
   wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
   cd nagios-plugins-1.4.16
   ./configure --with-nagios-user=nagios --with-nagios-group=nagios
   make
   make install
i) You try to open Web Interface page of Nagios.
   http://localhost/nagios
   OR  
   http://Server-IP-Address/nagios

Note: If page does not opens then in most cases there must be two reasons:

a) IPtables is blocking it so either disable iptables or modify rule to allow 80 port.
   service iptables stop
b) SELinux is not allowing to open the page, so use following command:
   chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
   chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

2 comments:

  1. Excellent post and wonderful blog, I really like this type of interesting articles keep it u.
    https://serveria.com

    ReplyDelete